在 Azure DevOps 的 ASP.NET Core / Blazor 项目集中显示版本
Displaying the version in an ASP.NET Core / Blazor project set from Azure DevOps
我想在我的 Blazor 应用程序上显示我在 Azure DevOps 管道中设置的版本。我在 DevOps 中使用 VersionDotNetCoreAssemblies
任务:
- 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
目前,我的 csproj
不包含 <Version />
属性,但据我所知,我认为这不是必需的。我的理解是 VersionDotNetCoreAssemblies
任务应该在必要时添加它。
如果相关,在我的 VersionDotNetCoreAssemblies
任务之后,我 运行 一个 dotnet restore
和一个 dotnet publish
.
我需要修改什么才能显示2022-01-25.10-Claims
的版本Number/Build?
AssemblyName.Version
属性 必须采用 0.0.0.0
格式,这就是为什么您的自定义内部版本号无法通过 VersionDotNetCoreAssemblies
任务转换为程序集版本的原因。它无法将破折号和字母数字字符转换为 numeric-only 格式。
您可以更改为适合 0.0.0.0
的内部版本号
请注意,20220126.3.0.0
作为版本号无效,因为 20220126 太大了。 。 2022.1.26.3
是有效的。您可以使用其他属性来存储您的版本,如评论中所述。
或从 DevOps 管道中获取内部版本号,并将其设置在您的应用可以访问的位置。这取决于您的主机。如果您使用 Docker,您可以在容器内设置一个变量,或者对于应用程序服务,您可以使用内部版本号设置应用程序设置。
在 DevOps 中,内部版本号位于名为“Build_BuildNumber”的环境变量中
我想在我的 Blazor 应用程序上显示我在 Azure DevOps 管道中设置的版本。我在 DevOps 中使用 VersionDotNetCoreAssemblies
任务:
- 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
目前,我的 csproj
不包含 <Version />
属性,但据我所知,我认为这不是必需的。我的理解是 VersionDotNetCoreAssemblies
任务应该在必要时添加它。
如果相关,在我的 VersionDotNetCoreAssemblies
任务之后,我 运行 一个 dotnet restore
和一个 dotnet publish
.
我需要修改什么才能显示2022-01-25.10-Claims
的版本Number/Build?
AssemblyName.Version
属性 必须采用 0.0.0.0
格式,这就是为什么您的自定义内部版本号无法通过 VersionDotNetCoreAssemblies
任务转换为程序集版本的原因。它无法将破折号和字母数字字符转换为 numeric-only 格式。
您可以更改为适合 0.0.0.0
请注意,20220126.3.0.0
作为版本号无效,因为 20220126 太大了。 2022.1.26.3
是有效的。您可以使用其他属性来存储您的版本,如评论中所述。
或从 DevOps 管道中获取内部版本号,并将其设置在您的应用可以访问的位置。这取决于您的主机。如果您使用 Docker,您可以在容器内设置一个变量,或者对于应用程序服务,您可以使用内部版本号设置应用程序设置。
在 DevOps 中,内部版本号位于名为“Build_BuildNumber”的环境变量中