-
Notifications
You must be signed in to change notification settings - Fork 392
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
Errors when building or running tests when PackageReference
version is set in .targets
file
#4698
Comments
It turns out there is further impact. In VS 2019 when you right-click "Migrate package.config to PackageReference" it fails the operation. It gets as far as removing the old references, but then shows the same failing call stack in the 'Package Manager' output window:
At this point the operation terminates without any error. Inspecting the .csproj file shows the old references gone but without any PackageReference elements at all. The workaround is to unload all other projects (at least all those that are dependencies that have been converted) and then do the migration. That does succeed. |
What you are trying to do would work with the new SDK-based project system, assuming you changed BeforeTargets from Build to CollectPackageReferences. This however, will not work in traditional .NET Framework projects. It only ever reads For that project system, you'll need to do something similar to https://github.com/davkean/maket, where the Update is added during evaluation. I'm not sure the benefit of the GlobalVersion metadata item? Is that so that you can verify that its not set in project file? |
Closing this. We do not have intentions on extending the support any further in the legacy project system, all of our investments are in the new project system, of which this already works. |
Visual Studio Version: 16.0.0 Preview 5.0
Summary
Errors when building or running tests when we attempt to set the
PackageReference
Version
metadata in a.targets
file.Why are we doing this? To centralize the nuget version for dozens of nugets in a 400+ project solution. We want the version to be blank in the csproj file and update it in a
Directory.Build.targets
file.Steps to Reproduce
Setup:
Version
metadata from aPackageReference
Version
metadata from aDirectory.Build.targets
fileThen:
Example
UnitTestProject1.csproj
:Directory.Build.targets
:Sample Project
I've completed these steps in this attached simplified solution. Simply run the one
UnitTestProject1.UnitTest1.TestMethod2
test.Expected Behavior
No errors.
Actual Behavior
Errors on build and on test discovery:
User Impact
Build and tests still complete but errors show up in logs.
Workaround
Setting the version to
*
gets us around the issue, but doesn't seem right.Possibly Related Issues
The text was updated successfully, but these errors were encountered: