Skip to content

Add .deps.json file for desktop web apps when PreserveCompilationContext = true #111

Closed

Description

@eerhardt

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.

Activity

  1. eerhardt commented on Sep 1, 2016

    @eerhardt
    MemberAuthor

    @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:

    1. It always assumes 'non-portable'
    2. 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?

  2. analogrelay commented on Sep 1, 2016

    @analogrelay
    Contributor

    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.

  3. self-assigned this
    on Oct 11, 2016
  4. nguerrera commented on Oct 11, 2016

    @nguerrera
    Contributor

    @anurse @pakrym @davidfowl - Can we make a final decision on this today?

    • Do we need to keep the deps file as a resource on desktop or can we put it next to the assembly on all platforms?
    • Do the differences @eerhardt highlighted above between the file that was embedded and the file generated by Publish need to remain?

    It would be cleaner to just have one kind of file and always deploy it to the same location.

  5. analogrelay commented on Oct 11, 2016

    @analogrelay
    Contributor

    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.

  6. pakrym commented on Oct 11, 2016

    @pakrym
    Contributor

    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.

  7. nguerrera commented on Oct 11, 2016

    @nguerrera
    Contributor

    Where do the DependencyContext tests live?

  8. NTaylorMullen commented on Dec 9, 2016

    @NTaylorMullen

    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

  9. dsplaisted commented on Dec 9, 2016

    @dsplaisted
    Member

    Reopening so this doesn't get lost and we can verify whether it's fixed or not.

  10. nguerrera commented on Dec 9, 2016

    @nguerrera
    Contributor

    @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.

  11. NTaylorMullen commented on Dec 9, 2016

    @NTaylorMullen

    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?

  12. nguerrera commented on Dec 9, 2016

    @nguerrera
    Contributor

    @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?

  13. pakrym commented on Dec 10, 2016

    @pakrym
    Contributor

    @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?

  14. NTaylorMullen commented on Dec 10, 2016

    @NTaylorMullen

    Yes

  15. nguerrera commented on Dec 10, 2016

    @nguerrera
    Contributor

    I'll try the repro steps in linked bugs and see if there's something incorrect in the deps file.

  16. nguerrera commented on Dec 12, 2016

    @nguerrera
    Contributor

    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.

  17. CZEMacLeod commented on Apr 8, 2017

    @CZEMacLeod

    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

      <PropertyGroup>
        <AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.deps.json</AllowedReferenceRelatedFileExtensions>
      </PropertyGroup>
    

    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.

  18. added a commit that references this issue on Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions