Description
Issue Description
I think I'm getting MSB4096
in this situation even though in this context, it isn't a problem. Repro build.proj
that gets MSB4096
:
<Project>
<Target Name="Build">
<ItemGroup>
<PackageReference Include="Foo" Version="1.0.0" />
<Other Include="Other" ExactVersion="1.0.0" />
<PackageReference Include="@(Other)" Version="[%(ExactVersion)]" /> <!-- MSB4096: must be Other.ExactVersion -->
</ItemGroup>
</Target>
</Project>
MSB4096's message is actionable and the workaround is easy, but it doesn't seem necessary based on my understanding of MSBuild, and I want to make sure I'm not missing some situation where the Version
metadata actually has the potential to get replaced in a way I don't expect.
(I expect to be called out on this in a code review: my diff changes ExactVersion
to Other.ExactVersion
for no obvious reason. 😄 My PR goes from not having any pre-existing PackageReference
s to adding Foo
, causing MSB4096
. Then I have to replace ExactVersion
with Other.ExactVersion
to fix that--this ends up being spooky action at a distance, and hard to review.)
Steps to Reproduce
With above repro project:
$ dotnet msbuild /bl
Expected Behavior
Success
Actual Behavior
error MSB4096: The item "Foo" in item list "PackageReference" does not define a value for
metadata "ExactVersion". In order to use this metadata, either qualify it by specifying
%(PackageReference.ExactVersion), or ensure that all items in this list define a value for
this metadata.
Workaround
Replace the last item list line with <PackageReference Include="@(Other)" Version="[%(Other.ExactVersion)]" />
.
Versions & Configurations
$ dotnet msbuild /version
Microsoft (R) Build Engine version 16.7.0-preview-20360-03+188921e2f for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
16.7.0.36003