Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor targets #89

Merged
merged 3 commits into from
Nov 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions MinVer/build/MinVer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@

<Target Name="MinVer_GetVersion" Condition=" '$(MinVerVersion)' == '' ">
<Error Condition="'$(MinVerVerbose)' != '' And '$(MinVerVerbose)' != 'true' And '$(MinVerVerbose)' != 'false'" Code="MINVER0003" Text="MinVerVerbose/MINVER_VERBOSE value '$(MinVerVerbose)' cannot be converted to a Boolean value." />
<PropertyGroup>
<MinVerVerboseOption Condition="'$(MinVerVerbose)' == 'true'"> --verbose</MinVerVerboseOption>
</PropertyGroup>
<Exec Command="dotnet &quot;$(MSBuildThisFileDirectory)../MinVer/MinVer.Cli.dll&quot; --build-metadata &quot;$(MINVER_BUILD_METADATA)&quot; --path &quot;$(MSBuildProjectDirectory)&quot; --major-minor &quot;$(MinVerMajorMinor)&quot; --tag-prefix &quot;$(MinVerTagPrefix)&quot;$(MinVerVerboseOption)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" ItemName="MinVerConsoleOutputItems" />
<ItemGroup>
<MinVerOptions Include="--build-metadata &quot;$(MINVER_BUILD_METADATA)&quot;" />
<MinVerOptions Include="--major-minor &quot;$(MinVerMajorMinor)&quot;" />
<MinVerOptions Include="--path &quot;$(MSBuildProjectDirectory)&quot;" />
<MinVerOptions Include="--tag-prefix &quot;$(MinVerTagPrefix)&quot;" />
<MinVerOptions Include="--verbose" Condition="'$(MinVerVerbose)' == 'true'" />
</ItemGroup>
<Exec Command="dotnet &quot;$(MSBuildThisFileDirectory)../MinVer/MinVer.Cli.dll&quot; @(MinVerOptions->'%(Identity)', ' ')" ConsoleToMSBuild="true">
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bording do you have an opinion on this change? It's more lines, but it gets rid of MinVerVerboseOption and the 212 character options expression, which also had to have a placeholder for MinVerVerboseOption, and that had to include it's leading space separator, which always felt a bit ugly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! Much cleaner, and it would be easier to add new options in the future that way.

<Output TaskParameter="ConsoleOutput" ItemName="MinVerOutput" />
</Exec>
<ItemGroup>
<MinVerConsoleOutputVersion Include="@(MinVerConsoleOutputItems)" Condition="'$([System.String]::new(`%(Identity)`).StartsWith(`MinVer:`))' != 'true'" />
<MinVerStdout Include="@(MinVerOutput)" Condition="'$([System.String]::new(`%(Identity)`).StartsWith(`MinVer:`))' != 'true'" />
</ItemGroup>
<PropertyGroup>
<MinVerVersion>@(MinVerConsoleOutputVersion)</MinVerVersion>
<MinVerVersion>@(MinVerStdout)</MinVerVersion>
</PropertyGroup>
</Target>

<Target Name="MinVer_UsingOverride" BeforeTargets="MinVer_GetVersion" Condition=" '$(MinVerVersion)' != '' ">
<Target Name="MinVer_LogOverride" BeforeTargets="MinVer_GetVersion" Condition=" '$(MinVerVersion)' != '' ">
<Message Text="MinVer: Using version override $(MinVerVersion)." Importance="high" />
</Target>

Expand All @@ -37,7 +41,7 @@
</PropertyGroup>
</Target>

<Target Name="MinVer_Warnings" BeforeTargets="MinVer" Condition="'$(DesignTimeBuild)' != 'true'">
<Target Name="MinVer_EnsureSdk" BeforeTargets="MinVer" Condition="'$(DesignTimeBuild)' != 'true'">
<Error Condition="'$(UsingMicrosoftNETSdk)' != 'true'" Code="MINVER0002" Text="MinVer only works in SDK-style projects." />
</Target>

Expand Down