问题描述
我是 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
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/[email protected]
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/[email protected]
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 的输出设置。我有两个问题
-
我怎样才能获得的NuGet软件包正确使用
GitVersion.AssemblySemVer
变量更新? -
在我上面两个项目的 .csproj 中,我仍然按如下方式动态设置版本
<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>
我仅需要在上取下AssemblyVersion
和Version
属性?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)