如何在git合并时自动递增nuget包版本

wljmcqd8  于 2022-12-10  发布在  Git
关注(0)|答案(1)|浏览(100)

我有nuget包,现在我在.csproj文件中手动对其进行版本控制。

<PropertyGroup>
     <TargetFramework>netstandard2.1</TargetFramework>
     <ImplicitUsings>enable</ImplicitUsings>
     <LangVersion>10.0</LangVersion>
     <Version>1.1.0</Version>
  </PropertyGroup>

我想实现自动增量时,合并请求被合并到主。我不需要它被保存在版本中。csproj(虽然它将是很好的有),但主要目标是已生成新的nuget与更高的版本。
当前管道仅执行简单上载它工作正常,但仅使用预定义版本

script:
   - echo "Creating nuget"
   - dotnet restore
   - dotnet build -c release
   - dotnet pack -c release -o publish
   - dotnet nuget add source "${SOURCE}" --name gitlab --username "${TOKEN_NAME}" --password "${TOKEN_PASSWORD}" --store-password-in-clear-text
   - dotnet nuget push "publish/*.nupkg" --source gitlab

任何想法都会很有帮助。谢谢

jdg4fx2g

jdg4fx2g1#

看看GitVersion,它会根据标签、版本、提交等,对你的软件包进行语义版本化。
从理论上讲,这就像

echo "Creating nuget"
dotnet restore
dotnet tool install --global GitVersion.Tool --version 5.*
dotnet-gitversion
dotnet build -c release
dotnet pack -c release -o publish
etc...

但是在复制粘贴任何代码之前,您可能应该执行read the documentation

相关问题