dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.54k stars 10.05k forks source link

Setting ReferenceOutputAssembly to false for the blazor project in hosted asp.net core project issue #20763

Open nvmkpk opened 4 years ago

nvmkpk commented 4 years ago

Describe the bug

I have a blazor application hosted in asp.net core application. The blazor application references a razor component library containing static files. If I set ReferenceOutputAssembly to false for the blazor project reference in the hosted asp.net core project, the static files from the library are not served when run from visual studio. Sounds similar to #20567. Creating a new one because it was closed with just a workaround. I think there should be be a better fix without needing to reference the razor library in the hosted project.

To Reproduce

Run the attached project from visual studio while looking at browser console or network traffic. BlazorIssue.zip

Further technical details

javiercn commented 4 years ago

@nvmkpk thanks for contacting us.

The answer for this is the same as for the other issue. We don't have a way to know about your transitive dependencies if you set reference output assembly to false. This is how MSBuild works and not something we can workaround.

You need to reference the transitive libraries from the host project if you use referenceoutputassembly=false.

nvmkpk commented 4 years ago

That means you don't fully support setting ReferenceOutputAssembly to false. I don't know how this works but I can think of a way to fix this issue. I will see if I can fix this by adding a custom target to the MSBuild. Can you tell me if this is entirely handled by static web assets generation process?

nvmkpk commented 4 years ago

I have a hacky fix for this that works for my case but I think the real fix should be in core msbuild task that generates or reads the assembly reference cache file. Currently msbuild appears to ignore the dependencies of a reference that has ReferenceOutputAssembly set to false. It should instead add all the references of it with ReferenceOutputAssembly set to false unless they are also referenced directly or indirectly with ReferenceOutputAssembly not set to false. If you agree to it, please move/create/copy the issue in msbuild repository.

dazinator commented 4 years ago

I have some additional motivations and an alternative, have put that on seperate issue: https://github.com/dotnet/aspnetcore/issues/21536

ghost commented 4 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.