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

SDK writes package version to deps file in place of assembly version for project references #44042

Open
ericstj opened this issue Oct 10, 2024 · 5 comments
Assignees
Labels
Area-NetSDK needs team triage Requires a full team discussion

Comments

@ericstj
Copy link
Member

ericstj commented Oct 10, 2024

Describe the bug

The deps file is meant to contain AssemblyVersion and FileVersion for runtime files. This is used by the host when deciding if the assembly provided by the application is newer than one provided by the shared framework.

The SDK does this correctly for nuget packages and binary references, but writes the wrong value for project references. For project references you can see it will write the package version instead. This is because it's misusing the library version here:

To Reproduce

Try the repro: deps-assemblyversion-projectreference.zip

It prints all the assembly version info from the deps, you'll see:

File(AssemblyVersion)
test.dll()
Microsoft.Extensions.DependencyModel.dll(8.0.0.2)
wb.dll(0.0.0-this-is-a-package-version-not-an-assembly-version)
System.Private.CoreLib.dll(9.0.0.0)
Microsoft.VisualBasic.dll(10.0.0.0)
Microsoft.Win32.Primitives.dll(9.0.0.0)
mscorlib.dll(4.0.0.0)
netstandard.dll(2.1.0.0)
System.AppContext.dll(9.0.0.0)
...

Note the 0.0.0-this-is-a-package-version-not-an-assembly-version that's a problem.

This is particularly a problem for the WPF repo which is trying to test and needs to replace the windowsbase.dll from dotnet/runtime with their real copy, but could be a problem for anyone trying to use ProjectReferences to replace framework assemblies (common for folks testing the frameworks).

The fix is to read the assembly version just as is done for other files (and the file version) or pull it from the reference metadata (EG: FusionName msbuild metadata).

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Oct 10, 2024
@baronfel
Copy link
Member

@ericstj is this something that you'd want us to fix forward, or do we need to take care of this in already-released versions too?

@ericstj
Copy link
Member Author

ericstj commented Oct 10, 2024

I think it's fine to just do it in the latest version. The customers of this are us so I suspect it's fine to just have in latest. I know @JeremyKuhne needs this - it's possible @buyaa-n might need it for the fuzz testing work she's doing as well.

For anyone hitting this the workaround is to make the project sets a PackageVersion that matches its AssemblyVersion -- of course that won't work if the project actually needs to produce a package (like System.Text.Json, for example).

@ViktorHofer
Copy link
Member

ViktorHofer commented Nov 15, 2024

This affects dotnet/runtime#109852 which is failing because the vstest testhost (used by one of the host tests) doesn't upgrade to the latest STJ in the app output directory because the version in the deps.json file is 10.0.0-dev instead of 10.0.0.0. When I change the version to the latter (or even just 10.0.0 without the last digit) the newer STJ gets successfully loaded.

Image

@joeloff joeloff added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels Nov 18, 2024
@joeloff
Copy link
Member

joeloff commented Nov 18, 2024

I've started investigating this, will discuss more in triage on Tuesday

@ViktorHofer
Copy link
Member

ViktorHofer commented Nov 26, 2024

@joeloff kindly asking for an update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK needs team triage Requires a full team discussion
Projects
None yet
Development

No branches or pull requests

4 participants