Satellite assemblies omit assembly version attributes, only under `dotnet build`
See original GitHub issueRepro steps
git clone https://github.com/microsoft/vs-validation
cd vs-validation\src\Microsoft.VisualStudio.Validation
dotnet restore
dotnet build -f net45
Expected
The built satellite assemblies have an assembly version that matches the one in the primary output assembly.
Actual
The built satellite assemblies lack any version attributes, leaving the assemblies claiming a version of 0.0.0.0.
The detailed build log from dotnet build
includes this relevant portion:
1>Target "CoreGenerateSatelliteAssemblies" in file "C:\Program Files\dotnet\sdk\2.0.0-preview1-005842\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets" from project "C:\git\validation\src\Microsoft.VisualStudio.Validation\Microsoft.VisualStudio.Validation.csproj" (target "CreateSatelliteAssemblies" depends on it):
Building target "CoreGenerateSatelliteAssemblies" completely.
Output file "C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\cs\Microsoft.VisualStudio.Validation.resources.dll" does not exist.
Task "MakeDir"
Done executing task "MakeDir".
Task "WriteCodeFragment"
Emitted specified code into "C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\cs\Microsoft.VisualStudio.Validation.resources.cs".
Done executing task "WriteCodeFragment".
Task "Csc"
C:\Program Files\dotnet\sdk\2.0.0-preview1-005842\Roslyn\RunCsc.cmd /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Numerics.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /keyfile:C:\Users\andarno\.nuget\packages\microbuild.visualstudio\2.0.40\build\FinalPublicKey.snk /out:C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\cs\Microsoft.VisualStudio.Validation.resources.dll /resource:C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\Microsoft.Strings.cs.resources /target:library /deterministic+ /publicsign+ C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\cs\Microsoft.VisualStudio.Validation.resources.cs
Microsoft (R) Visual C# Compiler version 2.0.0.61325
Copyright (C) Microsoft Corporation. All rights reserved.
Done executing task "Csc".
When using msbuild.exe instead of dotnet build
, I get the expected behavior:
msbuild /t:rebuild /p:targetframework=net45
This produces properly versioned satellite assemblies. We see in the detailed build logs this time that instead of using csc.exe to generate them, the targets use AL.exe, which uses the version from the primary assembly explicitly as a template:
1>Target "GenerateSatelliteAssemblies" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\vsuvscore\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\git\validation\src\Microsoft.VisualStudio.Validation\Microsoft.VisualStudio.Validation.csproj" (target "CreateSatelliteAssemblies" depends on it):
Building target "GenerateSatelliteAssemblies" completely.
Output file "C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\cs\Microsoft.VisualStudio.Validation.resources.dll" does not exist.
Task "MakeDir"
Done executing task "MakeDir".
Using "AL" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "AL"
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\al.exe /culture:cs /delaysign+ /keyfile:C:\Users\andarno\.nuget\packages\microbuild.visualstudio\2.0.40\build\FinalPublicKey.snk /out:C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\cs\Microsoft.VisualStudio.Validation.resources.dll /template:C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\Microsoft.VisualStudio.Validation.dll /embed:C:\git\validation\src\..\obj\Microsoft.VisualStudio.Validation\Debug\net45\Microsoft.Strings.cs.resources
Microsoft (R) Assembly Linker version 14.0.1055.0
Copyright (C) Microsoft Corporation. All rights reserved.
Done executing task "AL".
This was originally reported https://github.com/AArnott/Nerdbank.GitVersioning/issues/131, discovered by @onovotny.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
Ok, let’s first fix this in sdk, then push to have our targets moved to msbuild in vnext.
@livarcocc The key point is that
CoreGenerateSatelliteAssemblies
relies on@(AssemblyAttribute)
but doesn’t work for projects with disabled assembly info generation (or just disabled version attributes) that use a customAssemblyInfo.cs
.