Skip to content

Commit

Permalink
Merge pull request #705 from adamralph/minver-clean-3.0
Browse files Browse the repository at this point in the history
don't run MinVer before Clean when packages are not generated on build
  • Loading branch information
adamralph authored Mar 8, 2022
2 parents 15f3995 + 94b6022 commit b6bf5ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion MinVer/build/MinVer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<NoWarn>$(NoWarn);NU5105</NoWarn>
</PropertyGroup>

<Target Name="MinVer" BeforeTargets="Clean;BeforeCompile;GetAssemblyVersion;CoreCompile" Condition="'$(DesignTimeBuild)' != 'true' AND '$(MinVerSkip)' != 'true'">
<Target Name="_MinVerClean" BeforeTargets="Clean" DependsOnTargets="MinVer" Condition="'$(GeneratePackageOnBuild)' == 'true'" />

<Target Name="MinVer" BeforeTargets="BeforeCompile;GetAssemblyVersion;CoreCompile" Condition="'$(DesignTimeBuild)' != 'true' AND '$(MinVerSkip)' != 'true'">
<Error Condition="'$(UsingMicrosoftNETSdk)' != 'true'" Code="MINVER0001" Text="MinVer only works in SDK-style projects." />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [input] MSBuildProjectDirectory=$(MSBuildProjectDirectory)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [input] MinVerAutoIncrement=$(MinVerAutoIncrement)" />
Expand Down
22 changes: 22 additions & 0 deletions MinVerTests.Packages/Cleaning.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
Expand Down Expand Up @@ -33,5 +34,26 @@ public static async Task PackagesAreCleaned(bool multiTarget)
// assert
Assert.Empty(packages.GetResultsInFullPath(path));
}

[Fact]
public static async Task MinVerDoesNotRunWhenPackagesAreNotGeneratedOnBuild()
{
// arrange
var path = MethodBase.GetCurrentMethod().GetTestDirectory();
await Sdk.CreateProject(path);

// act
var result = await Sdk.DotNet(
"clean",
path,
new Dictionary<string, string>
{
{ "GeneratePackageOnBuild", "false" },
{ "MinVerVerbosity", "diagnostic" },
});

// assert
Assert.DoesNotContain("minver:", result.StandardOutput, StringComparison.OrdinalIgnoreCase);
}
}
}

0 comments on commit b6bf5ff

Please sign in to comment.