Last active
December 8, 2023 00:35
-
-
Save Blokyk/72514a25e2a1fb266004c34f8a443db9 to your computer and use it in GitHub Desktop.
Generator reference refresh workaround (requires local nuget field)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<!-- ...normal msbuild stuff... --> | |
<PropertyGroup> | |
<PackageId>YOUR.GENERATOR.NAME</PackageId> | |
<Version>0.1</Version> <!-- Actual release version --> | |
<!-- Ensure dynamic verison is only visible to normal builds | |
and not the IDE --> | |
<_IsDesignTimeBuild>false</_IsDesignTimeBuild> | |
<_IsDesignTimeBuild Condition="'$(DesignTimeBuild)' == 'true'">true</_IsDesignTimeBuild> | |
<Version | |
Condition="'$(Configuration)'=='Debug' AND '$(_IsDesignTimeBuild)' != 'true'" | |
>$([System.DateTime]::UtcNow.ToString("yyyy.MMdd.HHmm.ss"))</Version> | |
<!-- Makes sure the <Version> property reflects the actual version string of | |
the package (leading zeroes are removed) --> | |
<!-- fixme: doesn't work on midnight (00:00) or when seconds = 0 --> | |
<Version Condition="'$(Configuration)'=='Debug' AND '$(_IsDesignTimeBuild)' != 'true'" | |
>$(Version.Replace(".0", ".").Replace(".0", ".").Replace(".0", "."))</Version> | |
</PropertyGroup> | |
<!-- Add the generated package to your local nuget feed --> | |
<Target Name="UpdateLocalPackage" AfterTargets="Pack"> | |
<Exec Condition="'$(Configuration)'=='Debug'" | |
Command="nuget add -Source YOUR_LOCAL_NUGET_FEED_PATH '$(OutputPath)$(PackageId).$(Version).nupkg'" | |
/> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment