我想在我在 Azure DevOps 管道中設定的 Blazor 應用程式上顯示一個版本。我VersionDotNetCoreAssemblies在 DevOps 中使用任務:
- task: VersionDotNetCoreAssemblies@2
inputs:
Path: 'src/Claims.Web'
VersionNumber: '$(Build.BuildNumber)'
Injectversion: True
FilenamePattern: '.csproj'
Field: 'Version'
OutputVersion: 'OutputedVersion'
AddDefault: true
記錄以下內容:
Source Directory: src/Claims.Web
Filename Pattern: .csproj
Version Number/Build Number: 2022-01-25.10-Claims
Version Filter to extract build number: \d \.\d \.\d \.\d
Field to update (all if empty): Version
Add default field (all if empty): true
Output: Version Number Parameter Name: OutputedVersion
Inject Version: true
SDK names: Microsoft.NET.Sdk
Using provided version number directly
Extracted Version: 2022-01-25.10-Claims
Matched the file 'Claims.Web.csproj' using the SDK name 'Microsoft.NET.Sdk'
Adding file Claims.Web.csproj as is a .NETCore Project
Will apply 2022-01-25.10-Claims to 1 files.
Getting just the PropertyGroup that contains the single version fields
Found <PropertyGroup> [1] blocks
The <Version> version is not present in the file so adding it
The src\Claims.Web\Claims.Web.csproj file only targets 1 framework
src\Claims.Web\Claims.Web.csproj - version applied
Set the output variable 'OutputedVersion' with the value 2022-01-25.10-Claims
(node:1484) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-01-25.10-Claims 是我想在網路上顯示的版本。所以,目前我在我的頁面上使用以下內容:
@GetType()?.Assembly?.GetName()?.Version?.ToString()
然而,這顯示 2022.0.0.0
目前, mycsproj不包含<Version />屬性,但我不認為這是必需的。我的理解是VersionDotNetCoreAssemblies任務應該在必要時添加它。
如果相關,在我的VersionDotNetCoreAssemblies任務之后,我運行 adotnet restore和 a dotnet publish。
我需要修改什么來顯示版本號/內部版本號2022-01-25.10-Claims?
uj5u.com熱心網友回復:
該AssemblyName.Version屬性必須采用格式0.0.0.0,這就是為什么您的自定義內部版本號無法通過VersionDotNetCoreAssemblies任務轉換為程式集版本的原因。它無法將破折號和字母數字字符轉換為純數字格式。
您可以更改為適合的內部版本號0.0.0.0
請注意,20220126.3.0.0作為版本號無效,因為 20220126 太大。看到這個答案。2022.1.26.3將是有效的。如評論中所述,您可以使用其他屬性來存盤您的版本。
或從 DevOps 管道中獲取內部版本號并將其設定在您的應用可以訪問的位置。這取決于您的主機。如果您使用 Docker,您可以在容器內設定變數,或者對于應用服務,您可以使用內部版本號設定應用程式設定。
在 DevOps 中,內部版本號位于名為“Build_BuildNumber”的環境變數中
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/422430.html
標籤:
