团队城市 vs-2017 Build 版本 [英] Team city vs-2017 Build version

查看:17
本文介绍了团队城市 vs-2017 Build 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 VS2017 中设置 dotnet 核心项目的构建版本?

How can I set the build version on dotnet core projects in VS2017?

是通过 powershell 的构建步骤在 .csproj 文件中包含 version 标签还是有更好的方法?

Is it through a build step over powershell to include the the version tag on .csproj file or is there a better way?

推荐答案

我已经使用以下脚本创建了一个 PowerShell 构建步骤并且运行良好:

I've created a PowerShell Build Step with the following script and worked fine:

$newBuildNumber = "%build.number%"

$files = Get-ChildItem -Path "*.csproj" -Recurse

foreach( $file in $files ) {
    Write-Host "Processing: " $file.Name
    $info = [xml] (Get-Content $file)

    if($info.Project.PropertyGroup.Version){
    $info.Project.PropertyGroup.Version = $newBuildNumber
    }
    else {
       $newChild = $info.CreateElement("Version")
       $newChild.set_InnerXml($newBuildNumber)

       $info.Project.PropertyGroup.AppendChild($newChild)
    }

    $info.Save($file)
}

这篇关于团队城市 vs-2017 Build 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆