Skip to content

Commit

Permalink
Standardize versions in project files (#440)
Browse files Browse the repository at this point in the history
Adds a target to output the computed version for each project, and
attempts to standardize how versions are composed. Specifically the
project system supports automatically computing
Version/PackageVersion/etc. with the right values if VersionPrefix and
VersionSuffix are specified (different outputs have separate
requirements for what formats are supported).
  • Loading branch information
JohnSchmeichel authored Jul 25, 2023
1 parent 364639b commit 5438e61
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ variables:
steps:
- template: build/build.yml
parameters:
nuspecProperties: 'VersionSuffix=-CI-$(Build.BuildNumber)'
nuspecProperties: 'VersionSuffix=CI-$(Build.BuildNumber)'
2 changes: 1 addition & 1 deletion .vsts-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ variables:
steps:
- template: build/build.yml
parameters:
nuspecProperties: 'VersionSuffix=-PR-$(Build.BuildNumber)'
nuspecProperties: 'VersionSuffix=PR-$(Build.BuildNumber)'
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ dotnet pack CredentialProvider.Microsoft --configuration Release
For CI builds, you can append a pre-release version:

```shell
dotnet pack CredentialProvider.Microsoft --configuration Release /p:NuspecProperties=VersionSuffix=-MyCustomVersion-2
dotnet pack CredentialProvider.Microsoft --configuration Release /p:NuspecProperties=VersionSuffix=MyCustomVersion-2
```

### Versioning

When releasing a new version, update the CredentialProviderVersion property in Build.props
When releasing a new version, update the CredentialProviderVersion property in Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<RootNamespace>NuGetCredentialProvider</RootNamespace>
<LangVersion>latest</LangVersion>
<ApplicationIcon>helpericons.ico</ApplicationIcon>
<Version>$(CredentialProviderVersion)</Version>
<PackageVersion>$(CredentialProviderVersion)</PackageVersion>
<VersionPrefix>$(CredentialProviderVersion)</VersionPrefix>
<NuspecFile>CredentialProvider.Microsoft.nuspec</NuspecFile>
<!-- Shouldn't need to set these explicitly, there may be a bug in dotnet pack -->
<NuspecProperties>$(NuspecProperties);Configuration=$(Configuration);Version=$(CredentialProviderVersion)$(VersionSuffix)</NuspecProperties>
<!-- Need to set properties explictly when using nuspec https://github.com/NuGet/Home/issues/6636#issuecomment-443280306 -->
<NuspecProperties Condition=" '$(VersionSuffix)' == '' ">$(NuspecProperties);Configuration=$(Configuration);Version=$(VersionPrefix)</NuspecProperties>
<NuspecProperties Condition=" '$(VersionSuffix)' != '' ">$(NuspecProperties);Configuration=$(Configuration);Version=$(VersionPrefix)-$(VersionSuffix)</NuspecProperties>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>Microsoft.NuGet.CredentialProvider</id>
<version>$Version$$VersionSuffix$</version>
<version>$Version$</version>
<title>Microsoft Credential Provider for NuGet</title>
<authors>Microsoft</authors>
<owners>microsoft,nugetvss</owners>
Expand Down
8 changes: 8 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@
</EmbeddedResource>
</ItemGroup>

<!--
Support for command line evaluation of properties
https://github.com/dotnet/msbuild/issues/3911#issuecomment-1478468822
-->
<Target Name="PrintVersion">
<Message Text="$(MSBuildProjectName):$(Version)" Importance="High" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.2$(VersionSuffix)</Version>
<VersionPrefix>0.1.2</VersionPrefix>
<Authors>Microsoft</Authors>
<Owners>Microsoft</Owners>
<Description>Azure Artifacts authentication library for credential providers.</Description>
Expand Down

0 comments on commit 5438e61

Please sign in to comment.