.net core 使用GitVersion和GitFlow更新AssemblyVersion/Version和NuGet包版本
我是GitFlow的新手。为了使用GitVersion来增加构建程序集信息和NuGet包版本,我创建了以下脚本.net core 使用GitVersion和GitFlow更新AssemblyVersion/Version和NuGet包版本,.net-core,yaml,nuget,git-flow,gitversion,.net Core,Yaml,Nuget,Git Flow,Gitversion,我是GitFlow的新手。为了使用GitVersion来增加构建程序集信息和NuGet包版本,我创建了以下脚本 name: Publish to NuGet on: push: branches: [ main ] pull_request: branches: [ main ] jobs: nuget-publish: runs-on: ubuntu-latest steps: - name: Checkout use
name: Publish to NuGet
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
nuget-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
source-url: https://api.nuget.org/v3/index.json
dotnet-version: 3.1.200
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_API_KEY}}
- name: Install GitVersion @5
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: '5.x'
updateAssemblyInfo: true
- name: Restore Dependencies
run: |
dotnet restore src/Blundergat.Protobuf/Blundergat.Protobuf.csproj
dotnet restore src/Blundergat.Messaging/Blundergat.Messaging.csproj
- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.9.7
with:
useConfigFile: true
- name: Display SemVer
run: |
echo "SemVer: $GITVERSION_SEMVER"
- name: Build
run: |
dotnet build src/Blundergat.Protobuf/Blundergat.Protobuf.csproj --configuration Release --no-restore
dotnet build src/Blundergat.Messaging/Blundergat.Messaging.csproj --configuration Release --no-restore
- name: Run Unit Tests
run: dotnet test src/Blundergat.Messaging.Test/Blundergat.Messaging.Test.csproj --no-restore --verbosity normal
- name: Publish to NuGet
run: |
mkdir __out
dotnet pack src/Blundergat.Protobuf/Blundergat.Protobuf.csproj -c Release -o __out --no-restore
dotnet pack src/Blundergat.Messaging/Blundergat.Messaging.csproj -c Release -o __out --no-restore
dotnet nuget push "./__out/*.nupkg" --skip-duplicate --no-symbols true --api-key ${{secrets.NUGET_API_KEY}}
rm -rf __out
这将运行,但我的NuGet软件包版本不是使用GitVersion的输出设置的。我有两个问题
GitVersion.AssemblySemVer
变量正确更新NuGet软件包
错误消息
错误消息
1.0.0.$([System.DateTime]::UtcNow.ToString(HHmm))
0.0.0.1
$(VersionSuffix)
0.0.1.0
$(VersionSuffix)
NA
卡穆文吉安
版权所有©Camuvingian 2020
Blundergat.Messaging 1.0
我是否只需要删除上面的AssemblyVersion
和Version
属性
<PropertyGroup>
<AssemblyName>Blundergat.Messaging</AssemblyName>
<RootNamespace>Blundergat.Messaging</RootNamespace>
<VersionSuffix>1.0.0.$([System.DateTime]::UtcNow.ToString(HHmm))</VersionSuffix>
<AssemblyVersion Condition=" '$(VersionSuffix)' == '' ">0.0.0.1</AssemblyVersion>
<AssemblyVersion Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</AssemblyVersion>
<Version Condition=" '$(VersionSuffix)' == '' ">0.0.1.0</Version>
<Version Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)</Version>
<Company>NA</Company>
<Authors>Camuvingian</Authors>
<Copyright>Copyright © Camuvingian 2020</Copyright>
<Product>Blundergat.Messaging 1.0</Product>
</PropertyGroup>