I'm creating a NuGet package in an Azure DevOps pipeline from a multi-targeted .NET library that targets .NET Standard 2.0 and .NET 4.5. The pipeline sets the version dynamically using a variable (PackageVersion, e.g., 1.1.9 or 1.1.9-preview), like this:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: $(csprojFilePath)
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
projects: $(csprojFilePath)
arguments: '--configuration $(BuildConfiguration) --no-restore /p:Version=$(PackageVersion) /p:InformationalVersion=$(PackageVersion)'
- task: DotNetCoreCLI@2
displayName: dotnet pack
inputs:
command: 'pack'
packagesToPack: $(csprojFilePath)
versioningScheme: 'byEnvVar'
versionEnvVar: 'PackageVersion'
Inside the .csproj I have:
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<Version>0.0.1-preview</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
After the pipeline runs, the resulting .nupkg contains two DLLs — one for each target framework.
The .NET 4.5 DLL correctly has the overridden version set by the pipeline (e.g., 1.1.10-preview) in its AssemblyVersion, FileVersion, and InformationalVersion.
The .NET Standard 2.0 DLL still contains the default version from the .csproj file in all its version fields.
The package manifest (.nuspec) shows the correct version, but the compiled DLL for .NET Standard 2.0 does not reflect the overridden values.
.NET 4.5:
.NET Standard 2.0:
Is there anything else I need to configure to ensure the version override applies to all target frameworks?

