Tags are ignore when using tag prefixes in repository with mupltiple projects
SamJ26 opened this issue · 3 comments
Version
4.0.0
To reproduce
Steps to reproduce the behaviour:
- Create new repository
- Add two .NET 5 console projects (one solution with two .NET 5 console projects)
- Add following code to
.csproj
of first project
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<Target Name="MyTarget" AfterTargets="MinVer">
<PropertyGroup>
<MinVerTagPrefix>project1-</MinVerTagPrefix>
<Version>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)</Version>
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase>
<MinVerIgnoreHeight>true</MinVerIgnoreHeight>
</PropertyGroup>
</Target>
<ItemGroup Label="Package References">
<PackageReference Include="MinVer" PrivateAssets="All" Version="4.0.0" />
</ItemGroup>
- Add following code to
.csproj
of second project
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<Target Name="MyTarget" AfterTargets="MinVer">
<PropertyGroup>
<MinVerTagPrefix>project2-</MinVerTagPrefix>
<Version>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)</Version>
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase>
<MinVerIgnoreHeight>true</MinVerIgnoreHeight>
</PropertyGroup>
</Target>
<ItemGroup Label="Package References">
<PackageReference Include="MinVer" PrivateAssets="All" Version="4.0.0" />
</ItemGroup>
(it differs only in MinVerTagPrefix
)
- Add and commit all the code into repository
- Add tag:
git tag -a project1-9.9.9 -m "Initial tag"
- Build the projects from root of your repository using
dotnet build
command - Examine assembly info e.g. in https://github.com/dnSpy/dnSpy
Expected behaviour
Assembly info for project1:
[assembly: AssemblyVersion("9.0.0.0")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MinVerDemo.Project1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("9.9.9.0")]
[assembly: AssemblyInformationalVersion("9.9.9")]
[assembly: AssemblyProduct("MinVerDemo.Project1")]
[assembly: AssemblyTitle("MinVerDemo.Project1")]
Important lines:
[assembly: AssemblyVersion("9.0.0.0")]
[assembly: AssemblyFileVersion("9.9.9.0")]
[assembly: AssemblyInformationalVersion("9.9.9")]
Actual behaviour
Assembly info for project1:
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MinVerDemo.Project1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0")]
[assembly: AssemblyProduct("MinVerDemo.Project1")]
[assembly: AssemblyTitle("MinVerDemo.Project1")]
Important lines:
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0")]
Additional context
You can clone my testing repository here: https://github.com/SamJ26/versioning-demo-minver
The HEAD of the repository is tagged with project1-9.9.9
tag.
You need to clone repository, build solution and examine .dll
generated for Project1
Observations
When I create tag without prefix using git tag -a 9.9.9 -m "Initial tag"
, assembly versions for both projects are correctly incremented to version 9.9.9
You are setting MinVer options in a target which runs after the MinVer target, therefore those options will never be used. Try moving them to the initial property group instead:
(BTW, I'm not sure what you're trying do with <Version>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)</Version>
but it doesn't seem right. I would suggest removing that entire target.)
<PropertyGroup>
<MinVerTagPrefix>project1-</MinVerTagPrefix>
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase>
<MinVerIgnoreHeight>true</MinVerIgnoreHeight>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="MinVer" PrivateAssets="All" Version="4.0.0" />
</ItemGroup>
Thanks for answer @adamralph 🙂. I changed my .csproj
according to your suggestion, so versioning already works.
But I have another question:
Why does <MinVerIgnoreHeight>true</MinVerIgnoreHeight>
cause that pre-release tag is not appended to computed version?
According to this test it's intended behaviour.
Does it mean that when using <MinVerIgnoreHeight>true</MinVerIgnoreHeight>
we can not create pre-release versions?
If yes, what about repositories which contains multiple projects, out of which I want to create pre-release nuget packages?
Why does
<MinVerIgnoreHeight>true</MinVerIgnoreHeight>
cause that pre-release tag is not appended to computed version?
Whether a tag contains an RTM version or a pre-release version makes no difference to the behaviour.
Does it mean that when using
<MinVerIgnoreHeight>true</MinVerIgnoreHeight>
we can not create pre-release versions?
No.