asp.net html 版本号,asp.net-core – 设置.NET Core项目的版本号

为什么不更改project.json文件中的值。使用

CakeBuild可以做这样的事情(优化可能)

Task("Bump").Does(() => {

var files = GetFiles(config.SrcDir + "**/project.json");

foreach(var file in files)

{

Information("Processing: {0}", file);

var path = file.ToString();

var trg = new StringBuilder();

var regExVersion = new System.Text.RegularExpressions.Regex("\"version\":(\\s)?\"0.0.0-\\*\",");

using (var src = System.IO.File.OpenRead(path))

{

using (var reader = new StreamReader(src))

{

while (!reader.EndOfStream)

{

var line = reader.ReadLine();

if(line == null)

continue;

line = regExVersion.Replace(line, string.Format("\"version\": \"{0}\",", config.SemVer));

trg.AppendLine(line);

}

}

}

System.IO.File.WriteAllText(path, trg.ToString());

}

});

那么如果你有一个依赖项目的UnitTest项目,使用“*”进行依赖解析。

另外,做dotnet还原之前做碰撞。我的订单如下所示:

Task("Default")

.IsDependentOn("InitOutDir")

.IsDependentOn("Bump")

.IsDependentOn("Restore")

.IsDependentOn("Build")

.IsDependentOn("UnitTest");

Task("CI")

.IsDependentOn("Default")

.IsDependentOn("Pack");

实际值,例如该版本来自于在构建脚本中导入单独的build.config文件:

#load "./buildconfig.cake"

var config = BuildConfig.Create(Context, BuildSystem);

public class BuildConfig

{

private const string Version = "5.0.0";

public readonly string SrcDir = "./src/";

public readonly string OutDir = "./build/";

public string Target { get; private set; }

public string Branch { get; private set; }

public string SemVer { get; private set; }

public string BuildProfile { get; private set; }

public bool IsTeamCityBuild { get; private set; }

public static BuildConfig Create(

ICakeContext context,

BuildSystem buildSystem)

{

if (context == null)

throw new ArgumentNullException("context");

var target = context.Argument("target", "Default");

var branch = context.Argument("branch", string.Empty);

var branchIsRelease = branch.ToLower() == "release";

var buildRevision = context.Argument("buildrevision", "0");

return new BuildConfig

{

Target = target,

Branch = branch,

SemVer = Version + (branchIsRelease ? string.Empty : "-b" + buildRevision),

BuildProfile = context.Argument("configuration", "Release"),

IsTeamCityBuild = buildSystem.TeamCity.IsRunningOnTeamCity

};

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值