├── .appveyor.yml ├── .codecov.yml ├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── build.yml │ └── release-drafter.yml ├── .gitignore ├── CodeCoverage.runsettings ├── License.txt ├── README.md ├── TurnerSoftware.BuildVersioning.sln ├── azure-pipelines.yml ├── images └── icon.png ├── renovate.json ├── src ├── Directory.Build.props ├── TurnerSoftware.BuildVersioning.Tool │ ├── AssemblyInternals.cs │ ├── BuildVersion.cs │ ├── BuildVersioner.cs │ ├── BuildVersioningOptions.cs │ ├── GitCommandRunner.cs │ ├── IGitCommandRunner.cs │ ├── IVersionDetailsProvider.cs │ ├── Program.cs │ ├── TurnerSoftware.BuildVersioning.Tool.csproj │ ├── VersionDetails.cs │ └── VersionDetailsProvider.cs └── TurnerSoftware.BuildVersioning │ ├── TurnerSoftware.BuildVersioning.csproj │ ├── build │ ├── TurnerSoftware.BuildVersioning.Integrations.targets │ └── TurnerSoftware.BuildVersioning.targets │ └── buildMultiTargeting │ └── TurnerSoftware.BuildVersioning.targets └── tests ├── Directory.Build.props └── TurnerSoftware.BuildVersioning.Tests ├── Tool ├── BuildVersionerTests.cs ├── GitCommandRunnerTests.cs └── VersionDetailsProviderTests.cs └── TurnerSoftware.BuildVersioning.Tests.csproj /.appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2022 2 | skip_branch_with_pr: true 3 | 4 | environment: 5 | # Disable the .NET logo in the console output. 6 | DOTNET_NOLOGO: true 7 | # Disable the .NET first time experience to skip caching NuGet packages and speed up the build. 8 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 9 | # Disable sending .NET CLI telemetry to Microsoft. 10 | DOTNET_CLI_TELEMETRY_OPTOUT: true 11 | 12 | BUILD_ARTIFACT_PATH: build-artifacts 13 | 14 | build_script: 15 | - ps: dotnet --info 16 | - ps: dotnet restore 17 | - ps: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true -bl:$env:BUILD_ARTIFACT_PATH/msbuild-build.binlog 18 | - ps: dotnet test --no-restore /p:SkipBuildVersioning=true 19 | - ps: dotnet pack --no-build -c Release /p:PackageOutputPath=$env:BUILD_ARTIFACT_PATH /p:ContinuousIntegrationBuild=true -bl:$env:BUILD_ARTIFACT_PATH/msbuild-pack.binlog 20 | 21 | test: false 22 | artifacts: 23 | - path: '**\$(BUILD_ARTIFACT_PATH)\*' -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: off -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Based on the EditorConfig from Roslyn 2 | # top-most EditorConfig file 3 | root = true 4 | 5 | [*.cs] 6 | indent_style = tab 7 | 8 | # Sort using and Import directives with System.* appearing first 9 | dotnet_sort_system_directives_first = true 10 | # Avoid "this." and "Me." if not necessary 11 | dotnet_style_qualification_for_field = false:suggestion 12 | dotnet_style_qualification_for_property = false:suggestion 13 | dotnet_style_qualification_for_method = false:suggestion 14 | dotnet_style_qualification_for_event = false:suggestion 15 | 16 | # Use language keywords instead of framework type names for type references 17 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion 18 | dotnet_style_predefined_type_for_member_access = true:suggestion 19 | 20 | # Suggest more modern language features when available 21 | dotnet_style_object_initializer = true:suggestion 22 | dotnet_style_collection_initializer = true:suggestion 23 | dotnet_style_coalesce_expression = true:suggestion 24 | dotnet_style_null_propagation = true:suggestion 25 | dotnet_style_explicit_tuple_names = true:suggestion 26 | 27 | # Prefer "var" everywhere 28 | csharp_style_var_for_built_in_types = true:suggestion 29 | csharp_style_var_when_type_is_apparent = true:suggestion 30 | csharp_style_var_elsewhere = true:suggestion 31 | 32 | # Prefer method-like constructs to have a block body 33 | csharp_style_expression_bodied_methods = false:none 34 | csharp_style_expression_bodied_constructors = false:none 35 | csharp_style_expression_bodied_operators = false:none 36 | 37 | # Prefer property-like constructs to have an expression-body 38 | csharp_style_expression_bodied_properties = when_on_single_line:suggestion 39 | csharp_style_expression_bodied_indexers = true:none 40 | csharp_style_expression_bodied_accessors = when_on_single_line:suggestion 41 | 42 | # Suggest more modern language features when available 43 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 44 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 45 | csharp_style_inlined_variable_declaration = true:suggestion 46 | csharp_style_throw_expression = true:suggestion 47 | csharp_style_conditional_delegate_call = true:suggestion 48 | 49 | # Newline settings 50 | csharp_new_line_before_open_brace = all 51 | csharp_new_line_before_else = true 52 | csharp_new_line_before_catch = true 53 | csharp_new_line_before_finally = true 54 | csharp_new_line_before_members_in_object_initializers = true 55 | csharp_new_line_before_members_in_anonymous_types = true 56 | 57 | # Misc 58 | csharp_space_after_keywords_in_control_flow_statements = true 59 | csharp_space_between_method_declaration_parameter_list_parentheses = false 60 | csharp_space_between_method_call_parameter_list_parentheses = false 61 | csharp_space_between_parentheses = false 62 | csharp_preserve_single_line_statements = false 63 | csharp_preserve_single_line_blocks = true 64 | csharp_indent_case_contents = true 65 | csharp_indent_switch_labels = true 66 | csharp_indent_labels = no_change 67 | 68 | # Custom naming conventions 69 | dotnet_naming_rule.non_field_members_must_be_capitalized.symbols = non_field_member_symbols 70 | dotnet_naming_symbols.non_field_member_symbols.applicable_kinds = property,method,event,delegate 71 | dotnet_naming_symbols.non_field_member_symbols.applicable_accessibilities = * 72 | 73 | dotnet_naming_rule.non_field_members_must_be_capitalized.style = pascal_case_style 74 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case 75 | 76 | dotnet_naming_rule.non_field_members_must_be_capitalized.severity = suggestion -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Turnerj -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/src" 5 | schedule: 6 | interval: daily 7 | 8 | - package-ecosystem: nuget 9 | directory: "/tests" 10 | schedule: 11 | interval: daily -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: '$RESOLVED_VERSION' 2 | tag-template: '$RESOLVED_VERSION' 3 | categories: 4 | - title: '🚀 Features' 5 | labels: 6 | - 'feature' 7 | - 'enhancement' 8 | - title: '🐛 Bug Fixes' 9 | labels: 10 | - 'bug' 11 | - 'bugfix' 12 | - title: '🧰 Maintenance' 13 | label: 14 | - 'dependencies' 15 | - 'maintenance' 16 | change-template: '- $TITLE by @$AUTHOR (#$NUMBER)' 17 | change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. 18 | version-resolver: 19 | major: 20 | labels: 21 | - 'major' 22 | minor: 23 | labels: 24 | - 'minor' 25 | patch: 26 | labels: 27 | - 'patch' 28 | default: patch 29 | template: | 30 | ## Changes 31 | 32 | $CHANGES 33 | 34 | ## 👨🏼‍💻 Contributors 35 | 36 | $CONTRIBUTORS -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | release: 8 | types: [ published ] 9 | 10 | env: 11 | # Disable the .NET logo in the console output. 12 | DOTNET_NOLOGO: true 13 | # Disable the .NET first time experience to skip caching NuGet packages and speed up the build. 14 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 15 | # Disable sending .NET CLI telemetry to Microsoft. 16 | DOTNET_CLI_TELEMETRY_OPTOUT: true 17 | 18 | BUILD_ARTIFACT_PATH: ${{github.workspace}}/build-artifacts 19 | 20 | jobs: 21 | build: 22 | name: Build ${{matrix.os}} 23 | runs-on: ${{matrix.os}} 24 | strategy: 25 | matrix: 26 | os: [ubuntu-latest, windows-latest, macOS-latest] 27 | steps: 28 | - name: Checkout 29 | uses: actions/checkout@v4 30 | - name: Install .NET SDKs 31 | uses: actions/setup-dotnet@v4.3.0 32 | with: 33 | dotnet-version: | 34 | 6.0.x 35 | 8.0.x 36 | - name: .NET info 37 | run: dotnet --info 38 | - name: Install dependencies 39 | run: dotnet restore 40 | - name: Build 41 | run: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true -bl:${{env.BUILD_ARTIFACT_PATH}}/msbuild-build.binlog 42 | - name: Test with Coverage 43 | run: dotnet test --no-restore --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings /p:SkipBuildVersioning=true 44 | - name: Pack 45 | run: dotnet pack --no-build -c Release /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}} /p:ContinuousIntegrationBuild=true -bl:${{env.BUILD_ARTIFACT_PATH}}/msbuild-pack.binlog 46 | - name: Publish artifacts 47 | uses: actions/upload-artifact@v4 48 | if: always() 49 | with: 50 | name: ${{matrix.os}} 51 | path: ${{env.BUILD_ARTIFACT_PATH}} 52 | 53 | coverage: 54 | name: Process code coverage 55 | runs-on: ubuntu-latest 56 | needs: build 57 | steps: 58 | - name: Checkout 59 | uses: actions/checkout@v4 60 | - name: Download coverage reports 61 | uses: actions/download-artifact@v4 62 | - name: Install ReportGenerator tool 63 | run: dotnet tool install -g dotnet-reportgenerator-globaltool 64 | - name: Prepare coverage reports 65 | run: reportgenerator -reports:*/coverage/*/coverage.cobertura.xml -targetdir:./ -reporttypes:Cobertura 66 | - name: Upload coverage report 67 | uses: codecov/codecov-action@v5.3.1 68 | with: 69 | file: Cobertura.xml 70 | fail_ci_if_error: false 71 | - name: Save combined coverage report as artifact 72 | uses: actions/upload-artifact@v4 73 | with: 74 | name: coverage-report 75 | path: Cobertura.xml 76 | 77 | push-to-github-packages: 78 | name: 'Push GitHub Packages' 79 | needs: build 80 | if: github.ref == 'refs/heads/main' || github.event_name == 'release' 81 | environment: 82 | name: 'GitHub Packages' 83 | url: https://github.com/TurnerSoftware/BuildVersioning/packages 84 | permissions: 85 | packages: write 86 | runs-on: ubuntu-latest 87 | steps: 88 | - name: 'Download build' 89 | uses: actions/download-artifact@v4 90 | with: 91 | name: 'ubuntu-latest' 92 | - name: 'Add NuGet source' 93 | run: dotnet nuget add source https://nuget.pkg.github.com/TurnerSoftware/index.json --name GitHub --username Turnerj --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text 94 | - name: 'Upload NuGet package' 95 | run: dotnet nuget push *.nupkg --api-key ${{secrets.GH_PACKAGE_REGISTRY_API_KEY}} --source GitHub --skip-duplicate 96 | 97 | push-to-nuget: 98 | name: 'Push NuGet Packages' 99 | needs: build 100 | if: github.event_name == 'release' 101 | environment: 102 | name: 'NuGet' 103 | url: https://www.nuget.org/packages/TurnerSoftware.BuildVersioning 104 | runs-on: ubuntu-latest 105 | steps: 106 | - name: 'Download build' 107 | uses: actions/download-artifact@v4 108 | with: 109 | name: 'ubuntu-latest' 110 | - name: 'Upload NuGet package and symbols' 111 | run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: release-drafter/release-drafter@v6 13 | env: 14 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /CodeCoverage.runsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cobertura 8 | [TurnerSoftware.BuildVersioning.Tests]* 9 | [TurnerSoftware.BuildVersioning]*,[TurnerSoftware.BuildVersioning.*]* 10 | Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute 11 | true 12 | true 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Turner Software 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 
2 | 3 | ![Icon](images/icon.png) 4 | # Build Versioning 5 | 6 | Simple build versioning for .NET, powered by Git tags. 7 | 8 | ![Build](https://img.shields.io/github/actions/workflow/status/TurnerSoftware/buildversioning/build.yml?branch=main) 9 | [![Codecov](https://img.shields.io/codecov/c/github/turnersoftware/BuildVersioning/main.svg)](https://codecov.io/gh/TurnerSoftware/BuildVersioning) 10 | [![NuGet](https://img.shields.io/nuget/v/TurnerSoftware.BuildVersioning.svg)](https://www.nuget.org/packages/TurnerSoftware.BuildVersioning/) 11 |
12 | 13 | ## Overview 14 | 15 | Inspired by [MinVer](https://github.com/adamralph/minver), Build Versioning is a different attempt at the same problem - to make versioning simple. 16 | The simplicity comes from how the version strings are generated and the built-in integrations. 17 | 18 | ## 🤝 Licensing and Support 19 | 20 | Build Versioning is licensed under the MIT license. It is free to use in personal and commercial projects. 21 | 22 | There are [support plans](https://turnersoftware.com.au/support-plans) available that cover all active [Turner Software OSS projects](https://github.com/TurnerSoftware). 23 | Support plans provide private email support, expert usage advice for our projects, priority bug fixes and more. 24 | These support plans help fund our OSS commitments to provide better software for everyone. 25 | 26 | ## 📖 Table of Contents 27 | - [Requirements](#requirements) 28 | - [Getting Started](#getting-started) 29 | - [Example Versions](#example-versions) 30 | - [CI Versioning Integrations](#integrations) 31 | - [Customizing Version Strings](#customizing-version-strings) 32 | - [Formatting Tags](#formatting-tags) 33 | - [Version Strings](#version-strings) 34 | - [Additional Settings](#additional-settings) 35 | 36 | ## 📋 Requirements 37 | 38 | - Your project must be using a modern SDK-style project file 39 | - One of the following .NET runtimes must be installed: 40 | - .NET 6 41 | - .NET 8 42 | 43 | The runtime requirement is so that Build Versioning itself can run. 44 | Your project though can target whatever version of .NET you want (Framework/Standard/Core etc). 45 | 46 | ## ⭐ Getting Started 47 | 48 | 1. [Install Build Versioning](https://www.nuget.org/packages/TurnerSoftware.BuildVersioning/)
49 | ```powershell 50 | PM> Install-Package TurnerSoftware.BuildVersioning 51 | ``` 52 | 2. There is no second step - *you're done!* 53 | 54 | The version information is extracted from the current state of the Git repository. 55 | From a tag that is [SemVer v2.0](https://semver.org/spec/v2.0.0.html) compliant, it can extract the major, minor, patch, pre-release and build metadata information. 56 | This information is then fed through a formatting system to generate specific [version strings](#Version-Strings). 57 | 58 | Additional information is provided from Git directly including the commit height (number of commits since the last tag) and the commit hash itself. 59 | 60 | ### Example Versions 61 | 62 | These examples use the default configuration after installing Build Versioning. 63 | 64 | |Example|Git Tag|Commit Height|Full Version|File Version|Assembly Version| 65 | |-|:-:|:-:|:-:|:-:|:-:| 66 | |New Release |1.2.4 |0|1.2.4+a4f31ea |1.2.4.0|1.0.0.0| 67 | |New Pre-Release |1.2.4-alpha|0|1.2.4-alpha+a4f31ea |1.2.4.0|1.0.0.0| 68 | |Main Branch / Active Development |1.2.4 |4|1.2.4-dev.4+a4f31ea |1.2.4.0|1.0.0.0| 69 | |Non-PR Commit via GitHub Actions |1.2.4 |4|1.2.4-dev.4+a4f31ea-github.432515|1.2.4.0|1.0.0.0| 70 | |PR Commit via GitHub Actions |1.2.4 |4|1.2.4-pr.17+a4f31ea-github.432515|1.2.4.0|1.0.0.0| 71 | 72 | ##
🛠 CI Versioning Integrations 73 | 74 | By default, Build Versioning provides rich pre-release and build metadata from the current CI environment. 75 | For pull requests, this will automatically have a pre-release defined which will include the PR number (eg. `1.2.4-pr.17`). 76 | For all commits, the build metadata will include the CI environment and a relevant build identifier (eg. `1.2.4+a4f31ea-github.432515`). 77 | 78 | ### Default Integrations 79 | 80 | |Integration|Configuration Tag|Notes| 81 | |-|-|-| 82 | |[GitHub Actions](https://github.com/features/actions)|``|Will perform a `git fetch` for tags that are missing by default for GitHub Actions. This specific behaviour can be disabled by setting `` to false.| 83 | |[Azure DevOps](https://azure.microsoft.com/en-us/services/devops/pipelines/)|``|| 84 | |[AppVeyor](https://www.appveyor.com/)|``|Will update the AppVeyor build name to match the build version. This specific behaviour can be disabled by setting `` to false.| 85 | 86 | ### Disabling an Integration 87 | 88 | Each integration can be individually disabled through configuration. For example, include the following in your project file to disable the GitHub Actions integration: 89 | 90 | ```xml 91 | false 92 | ``` 93 | 94 | ## ✏ Customizing Version Strings 95 | 96 | ### Formatting Tags 97 | 98 | These are formatting tags available for you to use for customizing your version strings. 99 | 100 | |Tag|Notes| 101 | |-|-| 102 | |`{Major}`|The major version retrieved from the Git tag. If there are no tags available, defaults to `0`.| 103 | |`{Major++}`|The major version retrieved from the Git tag incremented by 1. If this is a tagged release, the value will return the major version without increment.| 104 | |`{Minor}`|The minor version retrieved from the Git tag. If there are no tags available, defaults to `0`.| 105 | |`{Minor++}`|The minor version retrieved from the Git tag incremented by 1. If this is a tagged release, the value will return the minor version without increment.| 106 | |`{Patch}`|The patch version retrieved from the Git tag. If there are no tags available, defaults to `0`.| 107 | |`{Patch++}`|The patch version retrieved from the Git tag incremented by 1. If this is a tagged release, the value will return the patch version without increment.| 108 | |`{CommitHeight}`|The number of commits since the last tag. If there are no tags available, defaults to `0`.| 109 | |`{CommitHash}`|The first 7 characters of the most recent commit hash.| 110 | 111 | Additionally, the full version string supports two additional formatting tags. 112 | 113 | |Tag|Default Value|Configuration Tag|Description| 114 | |-|-|-|-| 115 | |`{PreRelease}`|`dev.{CommitHeight}`|``|The pre-release portion of the version. This will include the leading dash (`-`) if a pre-release is defined, otherwise blank. The value is overridden by the Git tag if this is a tagged release.| 116 | |`{BuildMetadata}`|`{CommitHash}`|``|The build metadata portion of the version. This will include the leading plus (`+`) if build metadata is defined, otherwise blank. The value is overridden by the Git tag if this is a tagged release and is defined in the tag.| 117 | 118 | 119 | ### Version Strings 120 | 121 | |Name|Configuration Tag|Default Value| 122 | |-|-|-| 123 | |📦 **Full Version**
aka. the "package" or "product" version, it is used for versioning the package itself and displayed in NuGet.|``|`{Major}.{Minor}.{Patch}{PreRelease}{BuildMetadata}`| 124 | |📄 **File Version**
A superficial version number, displayed by the OS. This is not used by the .NET runtime.|``|`{Major}.{Minor}.{Patch}.0`| 125 | |⚙ **Assembly Version**
Used by .NET for referencing the assembly when strong-named signing is enabled. Updating this by major version is advised.|``|`{Major}.0.0.0`| 126 | 127 | For more information on file version vs assembly version, [see the MSDN docs](https://docs.microsoft.com/en-us/troubleshoot/visualstudio/general/assembly-version-assembly-file-version). 128 | 129 | ##
🎛 Additonal Settings 130 | 131 | ### Disabling Build Versioning 132 | 133 | You can disable build versioning by setting `` in your project file to `true`. 134 | 135 | ### Enable Output Logging 136 | 137 | You can enable output logging for Build Versioning by specifying `` as `normal` (for basic logging) or `high` (for detailed logging). -------------------------------------------------------------------------------- /TurnerSoftware.BuildVersioning.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31025.194 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TurnerSoftware.BuildVersioning", "src\TurnerSoftware.BuildVersioning\TurnerSoftware.BuildVersioning.csproj", "{F7049F6B-9985-41A7-A911-EAE54EB8A708}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TurnerSoftware.BuildVersioning.Tool", "src\TurnerSoftware.BuildVersioning.Tool\TurnerSoftware.BuildVersioning.Tool.csproj", "{D796E0D8-9315-47F1-86BD-EA8958E5A7FA}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1EFB8EBA-39B4-472E-9DE3-2B25E902EE2C}" 11 | ProjectSection(SolutionItems) = preProject 12 | src\Directory.Build.props = src\Directory.Build.props 13 | EndProjectSection 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{790239FE-AB99-45EE-B764-23F4F351C61E}" 16 | ProjectSection(SolutionItems) = preProject 17 | .appveyor.yml = .appveyor.yml 18 | .codecov.yml = .codecov.yml 19 | .editorconfig = .editorconfig 20 | .gitignore = .gitignore 21 | azure-pipelines.yml = azure-pipelines.yml 22 | CodeCoverage.runsettings = CodeCoverage.runsettings 23 | License.txt = License.txt 24 | README.md = README.md 25 | EndProjectSection 26 | EndProject 27 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{EC91FA7D-31F4-4BB8-ABD1-2C142491D34C}" 28 | ProjectSection(SolutionItems) = preProject 29 | tests\Directory.Build.props = tests\Directory.Build.props 30 | EndProjectSection 31 | EndProject 32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TurnerSoftware.BuildVersioning.Tests", "tests\TurnerSoftware.BuildVersioning.Tests\TurnerSoftware.BuildVersioning.Tests.csproj", "{F97BCD71-3D0E-4B36-8BE5-B401A05E0829}" 33 | EndProject 34 | Global 35 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 36 | Debug|Any CPU = Debug|Any CPU 37 | Release|Any CPU = Release|Any CPU 38 | EndGlobalSection 39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 40 | {F7049F6B-9985-41A7-A911-EAE54EB8A708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {F7049F6B-9985-41A7-A911-EAE54EB8A708}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {F7049F6B-9985-41A7-A911-EAE54EB8A708}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {F7049F6B-9985-41A7-A911-EAE54EB8A708}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {D796E0D8-9315-47F1-86BD-EA8958E5A7FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {D796E0D8-9315-47F1-86BD-EA8958E5A7FA}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {D796E0D8-9315-47F1-86BD-EA8958E5A7FA}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {D796E0D8-9315-47F1-86BD-EA8958E5A7FA}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {F97BCD71-3D0E-4B36-8BE5-B401A05E0829}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {F97BCD71-3D0E-4B36-8BE5-B401A05E0829}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {F97BCD71-3D0E-4B36-8BE5-B401A05E0829}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {F97BCD71-3D0E-4B36-8BE5-B401A05E0829}.Release|Any CPU.Build.0 = Release|Any CPU 52 | EndGlobalSection 53 | GlobalSection(SolutionProperties) = preSolution 54 | HideSolutionNode = FALSE 55 | EndGlobalSection 56 | GlobalSection(NestedProjects) = preSolution 57 | {F7049F6B-9985-41A7-A911-EAE54EB8A708} = {1EFB8EBA-39B4-472E-9DE3-2B25E902EE2C} 58 | {D796E0D8-9315-47F1-86BD-EA8958E5A7FA} = {1EFB8EBA-39B4-472E-9DE3-2B25E902EE2C} 59 | {F97BCD71-3D0E-4B36-8BE5-B401A05E0829} = {EC91FA7D-31F4-4BB8-ABD1-2C142491D34C} 60 | EndGlobalSection 61 | GlobalSection(ExtensibilityGlobals) = postSolution 62 | SolutionGuid = {17BD2449-BDDF-40FB-A123-E2B7B927BF9C} 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - main 3 | 4 | jobs: 5 | - job: BuildApplication 6 | pool: 7 | vmImage: ubuntu-latest 8 | 9 | variables: 10 | BUILD_ARTIFACT_PATH: $(Build.ArtifactStagingDirectory) 11 | 12 | steps: 13 | - task: UseDotNet@2 14 | displayName: Install .NET 6 SDK 15 | inputs: 16 | version: 6.0.x 17 | - task: UseDotNet@2 18 | displayName: Install .NET 8 SDK 19 | inputs: 20 | version: 8.0.x 21 | 22 | - script: dotnet --info 23 | displayName: .NET info 24 | 25 | - script: dotnet restore 26 | displayName: Install dependencies 27 | 28 | - script: dotnet build --no-restore -c Release /p:ContinuousIntegrationBuild=true -bl:$(BUILD_ARTIFACT_PATH)/msbuild-build.binlog 29 | displayName: Build 30 | 31 | - script: dotnet test --no-restore /p:SkipBuildVersioning=true 32 | displayName: Test 33 | 34 | - script: dotnet pack --no-build -c Release /p:PackageOutputPath=$(BUILD_ARTIFACT_PATH) /p:ContinuousIntegrationBuild=true -bl:$(BUILD_ARTIFACT_PATH)/msbuild-pack.binlog 35 | displayName: Pack 36 | 37 | - task: PublishBuildArtifacts@1 38 | displayName: Publish artifacts 39 | inputs: 40 | ArtifactName: BuildVersioning 41 | pathToPublish: $(BUILD_ARTIFACT_PATH) 42 | -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TurnerSoftware/BuildVersioning/095a5224de5a65ed141112321ecab32a6e7475d8/images/icon.png -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "github>TurnerSoftware/.github:renovate-shared" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TurnerSoftware.BuildVersioning 5 | 6 | Turner Software 7 | 8 | $(AssemblyName) 9 | true 10 | MIT 11 | icon.png 12 | readme.md 13 | https://github.com/TurnerSoftware/BuildVersioning 14 | semver;semantic;versioning;git 15 | 16 | 17 | true 18 | true 19 | true 20 | snupkg 21 | 22 | Latest 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/AssemblyInternals.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("TurnerSoftware.BuildVersioning.Tests")] -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/BuildVersion.cs: -------------------------------------------------------------------------------- 1 | namespace TurnerSoftware.BuildVersioning.Tool; 2 | 3 | public record BuildVersion 4 | { 5 | public string FullVersion { get; init; } 6 | public string FileVersion { get; init; } 7 | public string AssemblyVersion { get; init; } 8 | } 9 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/BuildVersioner.cs: -------------------------------------------------------------------------------- 1 | namespace TurnerSoftware.BuildVersioning.Tool; 2 | 3 | internal class BuildVersioner(IVersionDetailsProvider versionDetailsProvider) 4 | { 5 | public BuildVersion GetBuildVersion(BuildVersioningOptions options) 6 | { 7 | var versionDetails = versionDetailsProvider.GetVersionDetails(); 8 | if (versionDetails is null) 9 | { 10 | return null; 11 | } 12 | 13 | if (!versionDetails.IsTaggedRelease && versionDetails.PreRelease is null && options.PreReleaseFormat?.Length > 0) 14 | { 15 | versionDetails = versionDetails with 16 | { 17 | PreRelease = options.PreReleaseFormat 18 | .Replace("{CommitHeight}", versionDetails.CommitHeight.ToString()) 19 | }; 20 | } 21 | 22 | if (options.BuildMetadataFormat?.Length > 0) 23 | { 24 | versionDetails = versionDetails with 25 | { 26 | BuildMetadata = options.BuildMetadataFormat 27 | .Replace("{CommitHash}", versionDetails.CommitHash) 28 | .Replace("{CommitHeight}", versionDetails.CommitHeight.ToString()) 29 | }; 30 | } 31 | 32 | var fullVersion = FormatFullVersion(options.FullVersionFormat, versionDetails); 33 | var fileVersion = FormatVersion(options.FileVersionFormat, versionDetails); 34 | var assemblyVersion = FormatVersion(options.AssemblyVersionFormat, versionDetails); 35 | 36 | return new BuildVersion 37 | { 38 | FullVersion = fullVersion, 39 | FileVersion = fileVersion, 40 | AssemblyVersion = assemblyVersion 41 | }; 42 | } 43 | 44 | private static string FormatFullVersion(string format, VersionDetails versionDetails) 45 | { 46 | if (string.IsNullOrEmpty(format)) 47 | { 48 | return format; 49 | } 50 | 51 | return FormatVersion(format, versionDetails) 52 | .Replace("{PreRelease}", versionDetails.PreRelease is null ? default : $"-{versionDetails.PreRelease}") 53 | .Replace("{BuildMetadata}", versionDetails.BuildMetadata is null ? default : $"+{versionDetails.BuildMetadata}"); 54 | } 55 | 56 | private static string FormatVersion(string format, VersionDetails versionDetails) 57 | { 58 | if (string.IsNullOrEmpty(format)) 59 | { 60 | return format; 61 | } 62 | 63 | var autoIncrement = versionDetails.IsTaggedRelease ? 0 : 1; 64 | return format 65 | .Replace("{Major}", versionDetails.MajorVersion.ToString()) 66 | .Replace("{Major++}", (versionDetails.MajorVersion + autoIncrement).ToString()) 67 | .Replace("{Minor}", versionDetails.MinorVersion.ToString()) 68 | .Replace("{Minor++}", (versionDetails.MinorVersion + autoIncrement).ToString()) 69 | .Replace("{Patch}", versionDetails.PatchVersion.ToString()) 70 | .Replace("{Patch++}", (versionDetails.PatchVersion + autoIncrement).ToString()) 71 | .Replace("{CommitHeight}", versionDetails.CommitHeight.ToString()) 72 | .Replace("{CommitHash}", versionDetails.CommitHash ?? "NOCANDO"); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/BuildVersioningOptions.cs: -------------------------------------------------------------------------------- 1 | namespace TurnerSoftware.BuildVersioning.Tool; 2 | 3 | public record BuildVersioningOptions 4 | { 5 | public string FullVersionFormat { get; init; } 6 | public string FileVersionFormat { get; init; } 7 | public string AssemblyVersionFormat { get; init; } 8 | public string PreReleaseFormat { get; init; } 9 | public string BuildMetadataFormat { get; init; } 10 | } 11 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/GitCommandRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | 5 | namespace TurnerSoftware.BuildVersioning.Tool; 6 | 7 | internal class GitCommandRunner : IGitCommandRunner 8 | { 9 | private static string RunCommand(string command) 10 | { 11 | using var process = new Process(); 12 | process.StartInfo = new ProcessStartInfo("git", command) 13 | { 14 | RedirectStandardOutput = true 15 | }; 16 | 17 | var waitOnExit = new TaskCompletionSource(); 18 | process.Exited += (s, e) => waitOnExit.SetResult(default); 19 | process.EnableRaisingEvents = true; 20 | 21 | try 22 | { 23 | process.Start(); 24 | } 25 | catch (Exception ex) 26 | { 27 | Console.Error.WriteLine(ex.Message); 28 | return null; 29 | } 30 | 31 | var standardOutputTask = process.StandardOutput.ReadToEndAsync(); 32 | 33 | Task.WaitAll(waitOnExit.Task, standardOutputTask); 34 | 35 | if (process.ExitCode != 0) 36 | { 37 | return null; 38 | } 39 | 40 | return standardOutputTask.Result; 41 | } 42 | 43 | public string GitDescribe() => RunCommand("describe --tags --abbrev=7 --always --long"); 44 | } 45 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/IGitCommandRunner.cs: -------------------------------------------------------------------------------- 1 | namespace TurnerSoftware.BuildVersioning.Tool; 2 | 3 | public interface IGitCommandRunner 4 | { 5 | /// 6 | /// Returns a result from `git describe` containing the tag name, number of commits from the tag (commit height) and a 7-character commit hash. 7 | /// 8 | /// 9 | /// Format with tag: {tag}-{commitHeight}-{commitHash}
10 | /// Format without tag: {commitHash} 11 | ///
12 | string GitDescribe(); 13 | } 14 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/IVersionDetailsProvider.cs: -------------------------------------------------------------------------------- 1 | namespace TurnerSoftware.BuildVersioning.Tool; 2 | 3 | public interface IVersionDetailsProvider 4 | { 5 | VersionDetails GetVersionDetails(); 6 | } 7 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CommandLine; 3 | using System.CommandLine.Invocation; 4 | using TurnerSoftware.BuildVersioning.Tool; 5 | 6 | var rootCommand = new RootCommand 7 | { 8 | new Option("--full-version-format") 9 | { 10 | IsRequired = true, 11 | Description = "The string to format for the full version." 12 | }, 13 | new Option("--file-version-format") 14 | { 15 | IsRequired = true, 16 | Description = "The string to format for the file version." 17 | }, 18 | new Option("--assembly-version-format") 19 | { 20 | IsRequired = true, 21 | Description = "The string to format for the assembly version." 22 | }, 23 | new Option("--prerelease-format", () => string.Empty) 24 | { 25 | Description = "The string to format for the pre-release." 26 | }, 27 | new Option("--build-metadata-format", () => string.Empty) 28 | { 29 | Description = "The string to format for the build metadata." 30 | } 31 | }; 32 | 33 | rootCommand.Description = "Build Versioning Tool"; 34 | 35 | rootCommand.Handler = CommandHandler.Create((fullVersionFormat, fileVersionFormat, assemblyVersionFormat, preReleaseFormat, buildMetadataFormat) => 36 | { 37 | var buildVersioner = new BuildVersioner(new VersionDetailsProvider(new GitCommandRunner())); 38 | var buildVersion = buildVersioner.GetBuildVersion(new BuildVersioningOptions 39 | { 40 | FullVersionFormat = fullVersionFormat, 41 | FileVersionFormat = fileVersionFormat, 42 | AssemblyVersionFormat = assemblyVersionFormat, 43 | PreReleaseFormat = preReleaseFormat, 44 | BuildMetadataFormat = buildMetadataFormat 45 | }); 46 | 47 | Console.WriteLine($"{buildVersion.FullVersion};{buildVersion.FileVersion};{buildVersion.AssemblyVersion}"); 48 | return 0; 49 | }); 50 | 51 | return rootCommand.InvokeAsync(args).Result; 52 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/TurnerSoftware.BuildVersioning.Tool.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | TurnerSoftware.BuildVersioning.Tool 5 | TurnerSoftware.BuildVersioning.Tool 6 | Simple build versioning for .NET, powered by Git tags (CLI Tool) 7 | $(PackageBaseTags) 8 | James Turner 9 | 10 | 11 | 12 | Exe 13 | net6.0;net8.0 14 | high 15 | TurnerSoftware.BuildVersioning.Tool 16 | true 17 | buildversioning 18 | 19 | 20 | 21 | <_BuildVersioningToolRuntime>$(TargetFramework) 22 | $(MSBuildThisFileDirectory)bin/$(Configuration) 23 | true 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/VersionDetails.cs: -------------------------------------------------------------------------------- 1 | namespace TurnerSoftware.BuildVersioning.Tool; 2 | 3 | public record VersionDetails 4 | { 5 | public int MajorVersion { get; init; } 6 | public int MinorVersion { get; init; } 7 | public int PatchVersion { get; init; } 8 | public string PreRelease { get; init; } 9 | public string BuildMetadata { get; init; } 10 | public string CommitHash { get; init; } 11 | public int CommitHeight { get; init; } 12 | public bool IsTaggedRelease { get; init; } 13 | } 14 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning.Tool/VersionDetailsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace TurnerSoftware.BuildVersioning.Tool; 4 | 5 | internal class VersionDetailsProvider(IGitCommandRunner gitDataProvider) : IVersionDetailsProvider 6 | { 7 | /// 8 | /// Parses the value from `git describe --tags --abbrev=7 --always` into specific version and commit information. 9 | /// 10 | /// 11 | /// 12 | /// Format with tag: {tag}-{commitHeight}-{commitHash}
13 | /// Format without tag: {commitHash} 14 | ///
15 | /// 16 | /// Tag format: {major}.{minor}.{patch}{-preRelease}{+buildMetadata}
17 | /// Tag can have a prefix which will be ignored. 18 | ///
19 | ///
20 | private static readonly Regex GitDescribeParser = new(@"(?:[a-z. ]+)?(?\d+).(?\d+).(?\d+)(?:-(?[a-z0-9][a-z0-9-.]+))?(?:\+(?[a-z0-9][a-z0-9-.]+))?-(?\d+)-(?\w+)|(?\w+)", RegexOptions.IgnoreCase); 21 | 22 | public VersionDetails GetVersionDetails() 23 | { 24 | var gitDetails = gitDataProvider.GitDescribe(); 25 | if (gitDetails is null) 26 | { 27 | return null; 28 | } 29 | 30 | var matchedGroups = GitDescribeParser.Match(gitDetails).Groups; 31 | 32 | if (matchedGroups["major"].Success) 33 | { 34 | return new VersionDetails 35 | { 36 | MajorVersion = int.Parse(matchedGroups["major"].Value), 37 | MinorVersion = int.Parse(matchedGroups["minor"].Value), 38 | PatchVersion = int.Parse(matchedGroups["patch"].Value), 39 | PreRelease = matchedGroups["preRelease"].Success ? matchedGroups["preRelease"].Value : default, 40 | BuildMetadata = matchedGroups["buildMetadata"].Success ? matchedGroups["buildMetadata"].Value : default, 41 | CommitHeight = int.Parse(matchedGroups["commitHeight"].Value), 42 | IsTaggedRelease = int.Parse(matchedGroups["commitHeight"].Value) == 0, 43 | CommitHash = matchedGroups["commitHash"].Value 44 | }; 45 | } 46 | else 47 | { 48 | return new VersionDetails 49 | { 50 | CommitHash = matchedGroups["commitHash"].Value 51 | }; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning/TurnerSoftware.BuildVersioning.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | TurnerSoftware.BuildVersioning 5 | TurnerSoftware.BuildVersioning 6 | Simple build versioning for .NET, powered by Git tags 7 | $(PackageBaseTags) 8 | James Turner 9 | 10 | 11 | 12 | net8.0 13 | true 14 | true 15 | false 16 | $(NoWarn);NU5100;NU5104 17 | high 18 | false 19 | 20 | 21 | 22 | $(MSBuildThisFileDirectory)../TurnerSoftware.BuildVersioning.Tool/bin/$(Configuration) 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning/build/TurnerSoftware.BuildVersioning.Integrations.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | true 6 | true 7 | true 8 | true 9 | 10 | 11 | 12 | pr.$(GITHUB_REF.Split('/')[2]) 13 | {CommitHash}-github.$(GITHUB_RUN_ID) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | pr.$(APPVEYOR_PULL_REQUEST_NUMBER) 22 | {CommitHash}-appveyor.$(APPVEYOR_BUILD_ID) 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | pr.$(Build_SourceBranch.Split('/')[2]) 31 | {CommitHash}-azuredevops.$(Build_BuildId) 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning/build/TurnerSoftware.BuildVersioning.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | $(GetPackageVersionDependsOn);BuildVersioning 6 | 7 | 8 | 9 | $(NoWarn);MSB3073;MSB4181 10 | 11 | 12 | 13 | $(MSBuildThisFileDirectory)../tools 14 | {Major}.{Minor}.{Patch}{PreRelease}{BuildMetadata} 15 | {Major}.{Minor}.{Patch}.0 16 | {Major}.0.0.0 17 | dev.{CommitHeight} 18 | {CommitHash} 19 | low 20 | 21 | 22 | 23 | $(MSBuildProjectName) 24 | $(BuildVersioningProjectReference)/$(TargetFramework) 25 | <_BuildVersioningMessagePrefix>Build Versioning ($(BuildVersioningProjectReference)) 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | <_BuildVersioningToolRuntime Condition="$(_DotnetInfo.Contains("NETCore.App 6.0"))">net6.0 34 | <_BuildVersioningToolRuntime Condition="$(_DotnetInfo.Contains("NETCore.App 8.0"))">net8.0 35 | 36 | 37 | 38 | 39 | $(BuildVersioningToolBasePath)/$(_BuildVersioningToolRuntime)/TurnerSoftware.BuildVersioning.Tool.dll 40 | 41 | 42 | 43 | 45 | 46 | 50 | 51 | 52 | <_BuildVersioningDebuggingMessage Condition="$(BuildVersioningLogLevel) == 'high'">high 53 | <_BuildVersioningInfoMessage Condition="$(BuildVersioningLogLevel) != 'low'">high 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | $(BuildVersioningOutput.Split(`;`)[0]) 76 | $(BuildVersioningOutput.Split(`;`)[1]) 77 | $(BuildVersioningOutput.Split(`;`)[2]) 78 | $(BuildFullVersion) 79 | $(BuildFileVersion) 80 | $(BuildAssemblyVersion) 81 | $(BuildFullVersion) 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/TurnerSoftware.BuildVersioning/buildMultiTargeting/TurnerSoftware.BuildVersioning.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 4 | 5 | 6 | -------------------------------------------------------------------------------- /tests/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Latest 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/TurnerSoftware.BuildVersioning.Tests/Tool/BuildVersionerTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using Moq; 5 | using TurnerSoftware.BuildVersioning.Tool; 6 | 7 | namespace TurnerSoftware.BuildVersioning.Tests.Tool; 8 | 9 | [TestClass] 10 | public class BuildVersionerTests 11 | { 12 | private static readonly BuildVersioningOptions DefaultBuildVersioningOptions = new() 13 | { 14 | FullVersionFormat = "{Major}.{Minor}.{Patch}{PreRelease}{BuildMetadata}", 15 | FileVersionFormat = "{Major}.{Minor}.{Patch}.0", 16 | AssemblyVersionFormat = "{Major}.0.0.0", 17 | PreReleaseFormat = "dev.{CommitHeight}", 18 | BuildMetadataFormat = "{CommitHash}" 19 | }; 20 | 21 | private static IEnumerable GetBuildVersionTestData() 22 | { 23 | yield return new object[] 24 | { 25 | "Null values", 26 | null, 27 | null, 28 | null 29 | }; 30 | yield return new object[] 31 | { 32 | "No formats specified", 33 | new VersionDetails { }, 34 | new BuildVersioningOptions { }, 35 | new BuildVersion { } 36 | }; 37 | yield return new object[] 38 | { 39 | "No Git tag", 40 | new VersionDetails { CommitHash = "abcdef" }, 41 | DefaultBuildVersioningOptions, 42 | new BuildVersion { FullVersion = "0.0.0-dev.0+abcdef", FileVersion = "0.0.0.0", AssemblyVersion = "0.0.0.0" } 43 | }; 44 | yield return new object[] 45 | { 46 | "Tagged release", 47 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, CommitHash = "abcdef", IsTaggedRelease = true }, 48 | DefaultBuildVersioningOptions, 49 | new BuildVersion { FullVersion = "1.2.4+abcdef", FileVersion = "1.2.4.0", AssemblyVersion = "1.0.0.0" } 50 | }; 51 | yield return new object[] 52 | { 53 | "Has commit height", 54 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, CommitHeight = 1, CommitHash = "abcdef" }, 55 | DefaultBuildVersioningOptions, 56 | new BuildVersion { FullVersion = "1.2.4-dev.1+abcdef", FileVersion = "1.2.4.0", AssemblyVersion = "1.0.0.0" } 57 | }; 58 | yield return new object[] 59 | { 60 | "Pre-release", 61 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, PreRelease = "alpha", CommitHeight = 4, CommitHash = "abcdef" }, 62 | DefaultBuildVersioningOptions, 63 | new BuildVersion { FullVersion = "1.2.4-alpha+abcdef", FileVersion = "1.2.4.0", AssemblyVersion = "1.0.0.0" } 64 | }; 65 | yield return new object[] 66 | { 67 | "Build metadata is overridden when format is defined", 68 | new VersionDetails { BuildMetadata = "custom.{CommitHash}", CommitHash = "abcdef" }, 69 | DefaultBuildVersioningOptions, 70 | new BuildVersion { FullVersion = "0.0.0-dev.0+abcdef", FileVersion = "0.0.0.0", AssemblyVersion = "0.0.0.0" } 71 | }; 72 | yield return new object[] 73 | { 74 | "Auto-increment tags", 75 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 3 }, 76 | new BuildVersioningOptions { FullVersionFormat = "{Major++}.{Minor++}.{Patch++}", FileVersionFormat = "{Major++}.{Minor++}.{Patch++}", AssemblyVersionFormat = "{Major++}.{Minor++}.{Patch++}" }, 77 | new BuildVersion { FullVersion = "2.3.4", FileVersion = "2.3.4", AssemblyVersion = "2.3.4" } 78 | }; 79 | yield return new object[] 80 | { 81 | "Don't auto-increment tags on tagged release", 82 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 3, IsTaggedRelease = true }, 83 | new BuildVersioningOptions { FullVersionFormat = "{Major++}.{Minor++}.{Patch++}", FileVersionFormat = "{Major++}.{Minor++}.{Patch++}", AssemblyVersionFormat = "{Major++}.{Minor++}.{Patch++}" }, 84 | new BuildVersion { FullVersion = "1.2.3", FileVersion = "1.2.3", AssemblyVersion = "1.2.3" } 85 | }; 86 | yield return new object[] 87 | { 88 | "Commit height available for pre-release", 89 | new VersionDetails { CommitHeight = 1, CommitHash = "abcdef" }, 90 | new BuildVersioningOptions { FullVersionFormat = "{Major}.{Minor}.{Patch}{PreRelease}", PreReleaseFormat = "commitHeight.{CommitHeight}" }, 91 | new BuildVersion { FullVersion = "0.0.0-commitHeight.1" } 92 | }; 93 | yield return new object[] 94 | { 95 | "Commit height and commit hash available for build metadata", 96 | new VersionDetails { CommitHeight = 1, CommitHash = "abcdef" }, 97 | new BuildVersioningOptions { FullVersionFormat = "{Major}.{Minor}.{Patch}{BuildMetadata}", BuildMetadataFormat = "commitHeight.{CommitHeight}-commitHash.{CommitHash}" }, 98 | new BuildVersion { FullVersion = "0.0.0+commitHeight.1-commitHash.abcdef" } 99 | }; 100 | } 101 | 102 | public static string GetBuildVersionTestName(MethodInfo methodInfo, object[] data) => data[0] as string; 103 | 104 | [DataTestMethod] 105 | [DynamicData(nameof(GetBuildVersionTestData), DynamicDataSourceType.Method, DynamicDataDisplayName = nameof(GetBuildVersionTestName))] 106 | public void GetBuildVersion(string testName, VersionDetails inputVersion, BuildVersioningOptions options, BuildVersion expected) 107 | { 108 | var versionDetailsProviderMock = new Mock(); 109 | versionDetailsProviderMock.Setup(c => c.GetVersionDetails()).Returns(inputVersion); 110 | var buildVersioner = new BuildVersioner(versionDetailsProviderMock.Object); 111 | 112 | var result = buildVersioner.GetBuildVersion(options); 113 | Assert.AreEqual(expected, result); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /tests/TurnerSoftware.BuildVersioning.Tests/Tool/GitCommandRunnerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using TurnerSoftware.BuildVersioning.Tool; 3 | 4 | namespace TurnerSoftware.BuildVersioning.Tests.Tool; 5 | 6 | [TestClass] 7 | public class GitCommandRunnerTests 8 | { 9 | [TestMethod] 10 | public void GitDescribe() 11 | { 12 | var gitCommandRunner = new GitCommandRunner(); 13 | 14 | var result = gitCommandRunner.GitDescribe(); 15 | 16 | Assert.IsFalse(result.StartsWith("fatal")); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/TurnerSoftware.BuildVersioning.Tests/Tool/VersionDetailsProviderTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using Moq; 5 | using TurnerSoftware.BuildVersioning.Tool; 6 | 7 | namespace TurnerSoftware.BuildVersioning.Tests.Tool; 8 | 9 | [TestClass] 10 | public class VersionDetailsProviderTests 11 | { 12 | private static IEnumerable GetVersionDetailsTestData() 13 | { 14 | yield return new object[] 15 | { 16 | null, 17 | null 18 | }; 19 | yield return new object[] 20 | { 21 | "abcdef", 22 | new VersionDetails { CommitHash = "abcdef" } 23 | }; 24 | yield return new object[] 25 | { 26 | "1.2.4-0-abcdef", 27 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, CommitHash = "abcdef", IsTaggedRelease = true } 28 | }; 29 | yield return new object[] 30 | { 31 | "1.2.4-1-abcdef", 32 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, CommitHeight = 1, CommitHash = "abcdef" } 33 | }; 34 | yield return new object[] 35 | { 36 | "1.2.4-alpha-4-abcdef", 37 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, PreRelease = "alpha", CommitHeight = 4, CommitHash = "abcdef" } 38 | }; 39 | yield return new object[] 40 | { 41 | "1.2.4-alpha+build.123-4-abcdef", 42 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, PreRelease = "alpha", BuildMetadata = "build.123", CommitHeight = 4, CommitHash = "abcdef" } 43 | }; 44 | yield return new object[] 45 | { 46 | "v1.2.4-alpha+build.123-4-abcdef", 47 | new VersionDetails { MajorVersion = 1, MinorVersion = 2, PatchVersion = 4, PreRelease = "alpha", BuildMetadata = "build.123", CommitHeight = 4, CommitHash = "abcdef" } 48 | }; 49 | } 50 | 51 | public static string GetVersionDetailsTestName(MethodInfo methodInfo, object[] data) => data[0] as string ?? "Null"; 52 | 53 | [DataTestMethod] 54 | [DynamicData(nameof(GetVersionDetailsTestData), DynamicDataSourceType.Method, DynamicDataDisplayName = nameof(GetVersionDetailsTestName))] 55 | public void GetVersionDetails(string gitDescribeString, VersionDetails expected) 56 | { 57 | var commandRunnerMock = new Mock(); 58 | commandRunnerMock.Setup(c => c.GitDescribe()).Returns(gitDescribeString); 59 | var versionDetailsProvider = new VersionDetailsProvider(commandRunnerMock.Object); 60 | 61 | var result = versionDetailsProvider.GetVersionDetails(); 62 | Assert.AreEqual(expected, result); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tests/TurnerSoftware.BuildVersioning.Tests/TurnerSoftware.BuildVersioning.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------