Skip to content

Avoid loading NuGet.targets if already loaded#4969

Merged
rainersigwald merged 1 commit into
dotnet:masterfrom
chipitsine:master
Feb 19, 2020
Merged

Avoid loading NuGet.targets if already loaded#4969
rainersigwald merged 1 commit into
dotnet:masterfrom
chipitsine:master

Conversation

@chipitsine
Copy link
Copy Markdown
Contributor

Signed-off-by: Ilya Shipitsin chipitsine@gmail.com

Signed-off-by: Ilya Shipitsin <chipitsine@gmail.com>
@rainersigwald
Copy link
Copy Markdown
Member

@chipitsine Can you provide some details about why this is needed?

cc @rrelyea, @jeffkl

@chipitsine
Copy link
Copy Markdown
Contributor Author

in complex environments NuGet.targets might be occasioanely imported many times

     xxx\Current\bin\Microsoft.Common.CurrentVersion.targets(6086,3): warning MSB4011: "xxx\Current\bin\NuGet.targets" cannot be imported again. It was already imported at "xxx\yyy.props (63,3)". This is most likely a build authoring error. This subsequent import will be ignored. [xxx\yyy.proj]

IsRestoreTargetsFileLoaded is property that means NuGet.targets is already imported

@rrelyea
Copy link
Copy Markdown

rrelyea commented Dec 12, 2019

Including @nkolev92

What is impact of loading multiple times in one project? Is there a repro of how this happens?

@rainersigwald
Copy link
Copy Markdown
Member

@rrelyea the impact is that warning (which could be treated as an error if a user has their build configured that way), and confusion around import ordering. This would only address the former.

I would also like to know more details about exactly what projects are causing this warning--what are the "complex environments" like?

@chipitsine
Copy link
Copy Markdown
Contributor Author

I'm afraid I cannot provide particular details due to some NDA.

but google shows similar issues

@chipitsine
Copy link
Copy Markdown
Contributor Author

yep, the impact is to mute warnings

@rainersigwald
Copy link
Copy Markdown
Member

@nkolev92, do you have a preference on this? The MSBuild team is willing to take it.

The only downside is that if you have a situation where you import NuGet.targets early, then in the normal location, it might be harder to set properties to configure NuGet behavior. That's true today if you're in that situation, but you get the warning.

One possible workaround: -warnAsMessage:MSB4011 on the command line should quiet this.

@nkolev92
Copy link
Copy Markdown
Contributor

I do not recall getting a lot of feedback (read: any) around duplicate imports of the NuGet targets file.
So I am inclined to say, I'm ok with this change.

Is there even a default template that could lead you to this situation?

Copy link
Copy Markdown
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Sounds like there weren't any real objections to doing this check, so let's go forward with it. Object ASAP if you care to, please. We'll merge ~tomorrow.

@rainersigwald
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

4 participants