Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Msbuild /p:AssemblyVersion不';t覆盖AssemblyInfo.cs参数_Msbuild_Azure Pipelines_.net Assembly_Msbuild Task - Fatal编程技术网

Msbuild /p:AssemblyVersion不';t覆盖AssemblyInfo.cs参数

Msbuild /p:AssemblyVersion不';t覆盖AssemblyInfo.cs参数,msbuild,azure-pipelines,.net-assembly,msbuild-task,Msbuild,Azure Pipelines,.net Assembly,Msbuild Task,我希望我的Azure管道覆盖位于AssemblyInfo.cs中的[assembly:AssemblyVersion(“1.1.6.0”)]和[AssemblyFileVersion(“1.1.6.0”)]字段。在生成任务中,我使用以下配置: - task: MSBuild@1 inputs: solution: '*.csproj' msbuildArguments:'/p:OutputPath=$(Build.ArtifactStagingDirectory)

我希望我的Azure管道覆盖位于
AssemblyInfo.cs
中的
[assembly:AssemblyVersion(“1.1.6.0”)]和
[AssemblyFileVersion(“1.1.6.0”)]
字段。在生成任务中,我使用以下配置:

- task: MSBuild@1
    inputs:
      solution: '*.csproj'
      msbuildArguments:'/p:OutputPath=$(Build.ArtifactStagingDirectory) /p:AssemblyVersion="$(Build.BuildNumber)"'

但是程序集的版本保持不变,相反,我希望它们与当前版本号相等。为什么不更新这些值?

要更新AssemblyVersion,可以在管道中使用任务

您需要首先安装此任务,进入右上角的市场,然后搜索装配信息

此任务包含两个子任务NetFramwork项目的装配信息NetFramework任务。和装配信息-NetCore@2NetCore项目的任务

例如,在生成任务之前将此任务添加到管道中

 - task: Assembly-Info-NetFramework@2
      inputs:
        FileNames: "**/AssemblyInfo.cs"
        VersionNumber: $(Build.BuildNumber)

/p允许您重写MSBuild属性,而不是代码。@谢谢HansPassant。那么,我该怎么做呢?你只展示了如何不去做,我们不知道为什么这是必要的,数字来自哪里。谷歌“c#在构建时设置程序集版本”以获得成功。