Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve assets from targeting pack #2774

Merged
merged 25 commits into from
Jan 11, 2019

Conversation

dsplaisted
Copy link
Member

First steps for dotnet/cli#10085

  • References "Targeting Packs" with ExcludeAssets="all", and resolves assets from the targeting packs directly (instead of going through the assets file)
  • References "Runtime Packs" if necessary to support self-contained publish (these still go through the assets file for now)
  • For now, hard-codes a KnownFrameworkReference to Microsoft.NETCore.App, and includes the RID graph directly. These will need to be added to core-sdk
  • The list of runtime packs for each KnownFrameworkReference, and the RIDs available, will also need to be supplied by core-sdk

@dsplaisted dsplaisted requested review from nguerrera, livarcocc, peterhuene and a team December 26, 2018 21:37
@livarcocc livarcocc added this to the 3.0.1xx milestone Dec 26, 2018
@dsplaisted
Copy link
Member Author

dsplaisted commented Jan 3, 2019

TODO: Need to add an implicit reference to the Platforms package which brings in the RID graph. Currently, this is being brought in as a package dependency of Microsoft.NETCore.App (even though we are excluding all assets from it). When we resolve to an installed targeting pack, we won't have this package reference, so we'll need to implicitly reference the Platforms package. Once we do dotnet/cli#10528 or pass the runtime graph to NuGet via NuGet/Home#7351, then we can remove the implicit Platforms package reference.

EDIT: Done

@dsplaisted
Copy link
Member Author

dsplaisted commented Jan 3, 2019

TODO: Before merging this PR, it would be nice to use a runtime.json that's bundled in dotnet/core-sdk (dotnet/cli#10104) instead of the copied version that's included in this PR.

EDIT: Done

@dsplaisted dsplaisted force-pushed the resolvetargetingpacks branch from e0a899d to a522481 Compare January 3, 2019 22:03
@dsplaisted dsplaisted force-pushed the resolvetargetingpacks branch from a522481 to 4303b79 Compare January 4, 2019 19:56
@dsplaisted
Copy link
Member Author

@peterhuene I could especially use your review of the changes to the apphost logic

Copy link
Contributor

@peterhuene peterhuene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM regarding the apphost changes and my feedback has been addressed.

I'll let Nick also sign off on this since he had additional comments.

@peterhuene
Copy link
Contributor

+1 on keeping RuntimeIdentifers modified for < 3.0 targeted apps. I've filed https://github.com/dotnet/cli/issues/10566 to clean this up.

@vitek-karas
Copy link
Member

@nguerrera Thanks a lot, I was able to repro the failure.
It is actually not order related. If the app is executed via dotnet.exe (running the dotnet.exe from the .dotnet folder in the repo) then it works, regardless of order.
If the app is executed via the apphost (the .exe which is in the app output) then it fails. The problem is that the apphost doesn't know about the custom location of the dotnet (the .dotnet folder in the repo).

I was able to run the app successfully through the apphost by setting the DOTNET_ROOT (or DOTNET_ROOT(x86) env variable to the .dotnet folder in the repo. Then it works just fine.

I'm not sure what the typical workflow is in this repo, but I think we should fix the sdk-build-env.bat generated into the artifacts folder (this is done in here). That script should set the DOTNET_ROOT and DOTNET_ROOT(x86) to make the apphost work with the repo-local dotnet install.

Overall this behavior is by design, at least for now. There are discussions about improvements in this area (make it so that dotnet.exe also recognizes the DOTNET_ROOT variable, so that the global dotnet.exe could be used but still run with the repo-local install for example, there are other discussions of being able to influence this behavior in global.json or similar as well), but nothing close to resolution or implementation.

@nguerrera
Copy link
Contributor

nguerrera commented Jan 9, 2019

Hmm. We are currently setting DOTNET_ROOT in dotnet run pending those discussions. Also, I tried running the dll with custom dotnet directly.

The error message is looking for hostpolicy in the correct custom location but the wrong shared framework. So I'm confused. I will double check all of the above.

@nguerrera
Copy link
Contributor

As far as workflow, I:

  • checked out this change
  • eng\dogfood.cmd
  • mkdir \temp\repro
  • cd \temp\repro
  • dotnet new mvc
  • dotnet run

Dogfood.cmd causes the build to use tasks and targets from the build of this repo. Sdk-build-env is just for building the repo, it will use tasks and targets from the "stage 0" / lkg the build downloaded.

I will make both of these set DOTNET_ROOT and write a doc on how they work, but I'm nearly certain this is a red herring. I won't be sure until I get to the office and retry my steps above.

@vitek-karas
Copy link
Member

Thanks for the description @nguerrera . I think I finally got the repro of the problem you're referring to... looking into it.

@vitek-karas
Copy link
Member

It's a bug in hostfxr. Not sure about fix yet.
It should work if the NetCoreApp version specified in the app equals the one specified in AspNet.App. If they are different we do resolve it correctly ("roll-forward"), but we screw up internal ordering and pick the wrong FX as the root FX - which leads to the error with hostpolicy.

@nguerrera
Copy link
Contributor

Is putting Microsoft.NETCore.App last a reasonable workaround? We could do that.

@nguerrera
Copy link
Contributor

I filed https://github.com/dotnet/core-setup/issues/4947 as a tracking issue.

Talking to @dsplaisted, sounds like a better workaround for now is not to write out netcoreapp at all when referencing one of the higher frameworks that will chain it in is referenced.

@vitek-karas
Copy link
Member

Either should work (putting it last, or omitting completely).
Thanks for creating the issue in core-setup.

@dsplaisted
Copy link
Member Author

@nguerrera @peterhuene @livarcocc I've added some more commits here, and this is ready for "final" review before merging :-)

Note that I copied in an ASP.NET Core target from Microsoft.AspNetCore.App. Per discussion with @natemcmaster, that functionality might be used in a unit test project which doesn't directly use the Web SDK. So he suggests we put it in the base SDK.

or earlier was referenced as a package. This didn't use the AssemblyAttribute item group, so we cannot
avoid duplicate AssemblyAttribute items without skipping this target altogether..
-->
<Target Name="_GetUserSecretsAssemblyAttribute"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we condition this target to only run when Microsoft.AspNetCore.App is referenced? If that targeting pack isn't reference, generated code may not compile since Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute would be undefined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that since you have to set the UserSecretsId property to enable this, it's probably not necessary to restrict this target to projects having an ASP.NET framework reference. If for some reason you want to set UserSecretsId without having it generate the attribute (e.g. if you aren't referencing ASP.NET), then you can always set GenerateUserSecretsAttribute to false.

Copy link
Contributor

@nguerrera nguerrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants