Open TFTomSun opened 5 years ago
@nguerrera can you help?
I think this may be dependent on how you are authoring your build package. It is possible that you are setting the version in a way that is only applicable in the inner loop of the build (for targetframework) instead of the outer loop (target frameworks).
@livarcocc is correct.
When you have multiple target frameworks, there are two different build contexts. The "outer build" loops over the target frameworks and performs an "inner build" on each. The "inner builds" are where all the traditional msbuild targets run: compilation, etc. So not everything can work in the outer build, anything that is specific to the target framework cannot. As such, NuGet lets you specify targets for inner and outer builds.
If you have things you want to run in outer build, you need a buildMultiTargeting folder. If you want the same logic in inner and outer build, you can duplicate the files or have one of them import the other.
This is the package structure:
PackageName.nupkg
build/
## These are used in "inner build"
PackageName.props
PackageName.targets
buildMultiTargeting/
# These are used in "outer build"
PackageName.props
PackageName.targets
@nguerrera Thanks for the details, i wasn't aware of that yet. Is there any further documentation for that or is there any possibility to see those outer and inner loops in the MSBuild log? If so, which log level do I need to set and for which keywords should I look for?
Does the outer build loop also exist on a single TargetFramework build? Or do I need to find out which part moves from the single loop to the outer loop on a multi target build?
Hi,
I have the same problem.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<Company>IP Parking BV</Company>
<Product>ParkBase Identity Common</Product>
<Description>ParkBase Identity Common</Description>
<Authors>Yvonne Arnoldus</Authors>
<Copyright>Copyright © 2006-2020 IP Parking BV</Copyright>
<VersionPrefix>1.0.0</VersionPrefix>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>ParkBase.Identity.Common</PackageId>
</PropertyGroup>
<Target Name="GetVersionInformation" BeforeTargets="PreBuildEvent" Condition="'$(AzureDevOps)'==''">
<!-- Get Commit Hash -->
<Exec Command="powershell.exe -ExecutionPolicy ByPass -File getcommithash.ps1" ConsoleToMSBuild="true" WorkingDirectory="$(SolutionDir)">
<Output TaskParameter="ConsoleOutput" PropertyName="CommitHash" />
</Exec>
<Message Text="Commit Hash: $(CommitHash)" Importance="High" />
<!-- Get Build Number -->
<Exec Command="powershell.exe -ExecutionPolicy ByPass -File getbuildnumber.ps1" ConsoleToMSBuild="true" WorkingDirectory="$(SolutionDir)">
<Output TaskParameter="ConsoleOutput" PropertyName="BuildNumber" />
</Exec>
<Message Text="Build Number: $(BuildNumber)" Importance="High" />
</Target>
<Target Name="SetVersionInformation" BeforeTargets="PreBuildEvent">
<!-- Set FileVersion -->
<CreateProperty Value="$(VersionPrefix).$(BuildNumber)">
<Output TaskParameter="Value" PropertyName="FileVersion" />
</CreateProperty>
<!-- Set Version -->
<CreateProperty Value="$(VersionPrefix).$(BuildNumber)-$(CommitHash)">
<Output TaskParameter="Value" PropertyName="Version" />
</CreateProperty>
<!-- Set Package Version -->
<CreateProperty Value="$(VersionPrefix).$(BuildNumber)">
<Output TaskParameter="Value" PropertyName="PackageVersion" />
</CreateProperty>
</Target>
</Project>
Works but when I change
I have created a build package that sets the Version property based on the current time. When I pack a project with TargetFramework .netcoreapp3.0, which reference this build package, the package version is applied correctly. When I pack the project with multiple TargetFrameworks (e.g. netcoreapp3.0;netcoreapp2.2;netcoreapp2.1) the build package is not loaded. The version of the package becomes 1.0.0 instead.
Edit: Even if I use
The build package is not loaded
if I use
instead, everything works as expected.
Edit: The build package targets netstandard1.1