You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add .deps.json file for desktop web apps when PreserveCompilationContext = true #111
MVC web apps that target the desktop framework need a .deps.json file in order to compile Razor views at runtime. However, desktop framework apps don't get a .deps.json file written next to the app. Instead, the file is added as a resource to the app's assembly.
We need to either mimic the CLI's behavior in MSBuild by adding the .deps.json file as a resource to the assembly, or we need to write out a .deps.json file next to the assembly for desktop web apps when PreserveCompilationContext = true.
What do you think about not compiling the .deps.json file as a resource for desktop, and instead just laying down a .deps.json file next to the app assembly?
This way we are consistent across .NET Core and desktop.
Looking at the existing CLI code, the .deps.json file that gets added as a resource to the assembly is not the same as the one that gets generated during Publish. They have the following differences:
It always assumes 'non-portable'
It never filters any 'platform' dependencies.
So, as it exists in the CLI, it is very "desktop" centric.
Maybe we only add the .deps.json file as a resource when PreserveCompilationContext = true on Desktop projects? And .NET Core projects only get it as a file next to the app assembly?
My main concern would be this would break apps built with the latest tools but using a version of DependencyContext (via MVC, most likely) that does not understand this new location for the deps file.
I believe putting the file next to the assembly will work, but @pakrym would need to confirm. If it would break apps compiled against 1.0.0 DependencyModel, we should probably continue to embed the file.
As for the differences, I believe they are all subsets of what would normally be in a "sidecar" deps file so as long as the deps file has at least those things, it should be fine.
Writing .deps file next to assembly only when PreserveCompilationContext = true should work fine even with old version of DependencyModel but needs to be tested. There is no portable/platform for desktop so we didn't care about filtering them out for embedded file.
Also make sure that DependencyContext functional tests run fine after this change.
Was this issue actually fixed? It doesn't look like preserveCompilationContext results in the correct bits getting embeded for desktop projects. Few issues sprung up due to this: dotnet/aspnetcore#1866 aspnet/Razor#890
@NTaylorMullen Please clarify. We agreed above that putting the .deps.json next to the assembly was the right call. Is the problem that deps.json is not embedded (by design, again see above) or that its contents are wrong?
Nobody answered my question about tests, but if something is expecting .deps.json to be embedded, it should be changed to also allow it to be on disk.
What I'm seeing is that File => New Web Application in VS 2017 RC fails to render Razor pages because preserveCompilationContext bits aren't being picked up. This ties back to Mvc 1.0.0 bits depending on older extensiosn.dependencymodel bits.
Does Microsoft.Extensions.DependencyModel 1.0.0 support reading deps.json next to the assembly? If not how should 1.0.0 runtime bits work with newer CLIs?
@pakrym said above that it "should work fine even with old version of DependencyModel but needs to be tested" and then I never got an answer on how to test. If it conclusively does not support it, then yes, we'll need to support embedding after all.
I'd like to understand better why it was believed that it "should work" but apparently does not. Is it just a bug in 1.0.0 that it's failing to read from disk? Is there a patch release possibility to fix this rather than adding embedding to SDK?
@nguerrera I said "should work" because Microsoft.Extensions.DependencyModel always reads from disk for .net core apps so this functionality is there and is tested. @NTaylorMullen is there a .deps file next to .exe when you build?
It's definitely reading from .deps.json on disk (editing it caused a different crash). I found that there are missing references for the Facades coming from desktop targeting path. I believe this is the root issue. I've filed #480 to track that and I'm re-closing this as it tracked producing the .deps.json file, which we do, it's just incomplete.
I know this is closed - but having been searching for a solution to DependencyContext not loading for class libraries since they no longer embed the .deps.json file - I found that I needed to add
to ensure that my ProjectReferences took across the file. I don't know if this should be a default now (like .pdb etc.) but it may help others tripping over this issue when using project references rather than build packages.
Activity
eerhardt commentedon Sep 1, 2016
@anurse @pakrym @davidfowl -
What do you think about not compiling the .deps.json file as a resource for desktop, and instead just laying down a .deps.json file next to the app assembly?
This way we are consistent across .NET Core and desktop.
Looking at the existing CLI code, the .deps.json file that gets added as a resource to the assembly is not the same as the one that gets generated during Publish. They have the following differences:
So, as it exists in the CLI, it is very "desktop" centric.
Maybe we only add the .deps.json file as a resource when PreserveCompilationContext = true on Desktop projects? And .NET Core projects only get it as a file next to the app assembly?
analogrelay commentedon Sep 1, 2016
My main concern would be this would break apps built with the latest tools but using a version of DependencyContext (via MVC, most likely) that does not understand this new location for the deps file.
nguerrera commentedon Oct 11, 2016
@anurse @pakrym @davidfowl - Can we make a final decision on this today?
It would be cleaner to just have one kind of file and always deploy it to the same location.
analogrelay commentedon Oct 11, 2016
I believe putting the file next to the assembly will work, but @pakrym would need to confirm. If it would break apps compiled against 1.0.0 DependencyModel, we should probably continue to embed the file.
As for the differences, I believe they are all subsets of what would normally be in a "sidecar" deps file so as long as the deps file has at least those things, it should be fine.
pakrym commentedon Oct 11, 2016
Writing
.depsfile next to assembly only whenPreserveCompilationContext = trueshould work fine even with old version of DependencyModel but needs to be tested. There is no portable/platform for desktop so we didn't care about filtering them out for embedded file.Also make sure that DependencyContext functional tests run fine after this change.
nguerrera commentedon Oct 11, 2016
Where do the DependencyContext tests live?
NTaylorMullen commentedon Dec 9, 2016
Was this issue actually fixed? It doesn't look like
preserveCompilationContextresults in the correct bits getting embeded for desktop projects. Few issues sprung up due to this:dotnet/aspnetcore#1866
aspnet/Razor#890
dsplaisted commentedon Dec 9, 2016
Reopening so this doesn't get lost and we can verify whether it's fixed or not.
nguerrera commentedon Dec 9, 2016
@NTaylorMullen Please clarify. We agreed above that putting the .deps.json next to the assembly was the right call. Is the problem that deps.json is not embedded (by design, again see above) or that its contents are wrong?
Nobody answered my question about tests, but if something is expecting .deps.json to be embedded, it should be changed to also allow it to be on disk.
NTaylorMullen commentedon Dec 9, 2016
What I'm seeing is that File => New Web Application in VS 2017 RC fails to render Razor pages because
preserveCompilationContextbits aren't being picked up. This ties back to Mvc 1.0.0 bits depending on older extensiosn.dependencymodel bits.Does
Microsoft.Extensions.DependencyModel 1.0.0support reading deps.json next to the assembly? If not how should 1.0.0 runtime bits work with newer CLIs?nguerrera commentedon Dec 9, 2016
@pakrym said above that it "should work fine even with old version of DependencyModel but needs to be tested" and then I never got an answer on how to test. If it conclusively does not support it, then yes, we'll need to support embedding after all.
I'd like to understand better why it was believed that it "should work" but apparently does not. Is it just a bug in 1.0.0 that it's failing to read from disk? Is there a patch release possibility to fix this rather than adding embedding to SDK?
pakrym commentedon Dec 10, 2016
@nguerrera I said "should work" because
Microsoft.Extensions.DependencyModelalways reads from disk for .net core apps so this functionality is there and is tested. @NTaylorMullen is there a.depsfile next to.exewhen you build?NTaylorMullen commentedon Dec 10, 2016
Yes
nguerrera commentedon Dec 10, 2016
I'll try the repro steps in linked bugs and see if there's something incorrect in the deps file.
nguerrera commentedon Dec 12, 2016
It's definitely reading from .deps.json on disk (editing it caused a different crash). I found that there are missing references for the Facades coming from desktop targeting path. I believe this is the root issue. I've filed #480 to track that and I'm re-closing this as it tracked producing the .deps.json file, which we do, it's just incomplete.
CZEMacLeod commentedon Apr 8, 2017
I know this is closed - but having been searching for a solution to DependencyContext not loading for class libraries since they no longer embed the .deps.json file - I found that I needed to add
to ensure that my ProjectReferences took across the file. I don't know if this should be a default now (like .pdb etc.) but it may help others tripping over this issue when using project references rather than build packages.
Merge pull request dotnet#111 from aspnet/TypeSciptImport
Set image working directory (dotnet#111)