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

Exclude package target/props imports during restore #3604

Closed
emgarten opened this issue Oct 5, 2016 · 1 comment
Closed

Exclude package target/props imports during restore #3604

emgarten opened this issue Oct 5, 2016 · 1 comment
Assignees
Labels

Comments

@emgarten
Copy link
Member

emgarten commented Oct 5, 2016

Now that NuGet supports PackageReference in msbuild files there is a potential for packages to include targets/props files under the build folder which change the dependencies of a project.

Problem

If a package contains a build/package.targets file that contains a PackageReference the output of restore will change based on if the project had previously been restored.

Proposal

NuGet should exclude targets/props from packages while restoring and provide properties which give control over imports in the auto generated targets/props files.

New properties

Property Details
ExcludeRestorePackageImports Excludes all targets/props from packages
ExcludeRestorePackageBuildImports Excludes targets/props from the build folder
ExcludeRestorePackageBuildCrossTargetingImports Excludes targets/props from the buildCrossTargeting folder

Usage

Restore will run with ExcludeRestorePackageImports=true

@emgarten emgarten self-assigned this Oct 11, 2016
@emgarten
Copy link
Member Author

This can be limited to just ExcludeRestorePackageImports, there are currently no scenarios for excluding build vs buildCrossTargeting

emgarten added a commit to NuGet/NuGet.Client that referenced this issue Oct 11, 2016
Framework conditions for targets/props are added only when a project uses cross targeting. For scenarios with a single framework under $(TargetFramework) buildCrossTargeting will be left out and there will be no framework conditions to block the imports.

In addition to this a new property has been added to allow control over package imports: ExcludeRestorePackageImports. This flag is used at restore time to avoid imports from packages changing the inputs to restore, without this it is possible to get different results between the first and second restore.

This change also contains support for nooping when writing out targets/props files. Currently the check is a simple string compare on the files since these files are small. Nooping is now a major benefit since all NETCore projects reference the SDK package, without nooping on the targets/props files MSBuild will always end up rebuilding everything for NETCore solutions.

Fixes NuGet/Home#3588
Fixes NuGet/Home#3637
Fixes NuGet/Home#3604
Fixes NuGet/Home#3641
Fixes NuGet/Home#3199
emgarten added a commit to NuGet/NuGet.Client that referenced this issue Oct 11, 2016
Framework conditions for targets/props are added only when a project uses cross targeting. For scenarios with a single framework under $(TargetFramework) buildCrossTargeting will be left out and there will be no framework conditions to block the imports.

In addition to this a new property has been added to allow control over package imports: ExcludeRestorePackageImports. This flag is used at restore time to avoid imports from packages changing the inputs to restore, without this it is possible to get different results between the first and second restore.

This change also contains support for nooping when writing out targets/props files. Currently the check is a simple string compare on the files since these files are small. Nooping is now a major benefit since all NETCore projects reference the SDK package, without nooping on the targets/props files MSBuild will always end up rebuilding everything for NETCore solutions.

Fixes NuGet/Home#3588
Fixes NuGet/Home#3637
Fixes NuGet/Home#3604
Fixes NuGet/Home#3641
Fixes NuGet/Home#3199
@nkolev92 nkolev92 added Style:PackageReference Type:DCR Design Change Request labels Jan 12, 2019
drewcassidy added a commit to KSPModdingLibs/KSPBuildTools that referenced this issue Sep 7, 2024
Due to NuGet/Home#3604, `restore` targets defined in nuget packages never get run. Luckily the ckaninstall stuff only runs when needed so having it under `build` is not the end of the world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants