【问题标题】:.Net Core build with TeamCity使用 TeamCity 构建 .Net Core
【发布时间】:2017-08-02 08:49:18
【问题描述】:

有人有使用 TeamCity 和 Octopus 构建 .net 核心应用的经验吗?我知道有各种指南可以实现这一点,但它们依赖于 Microsoft 已删除的 project.json 文件。有没有人提出任何解决方案?

我目前正在使用 TeamCity 建议的 dotnet-core-plugin - 但它似乎依赖于 project.json 文件

【问题讨论】:

    标签: continuous-integration teamcity .net-core devops teamcity-9.0


    【解决方案1】:

    您可以使用 FlubuCore。 Flubu 是我们为使用 C# 代码构建项目和执行部署脚本而编写的 C# 库。

    flubu 如何在.net core 中使用的简单示例

        protected override void ConfigureTargets(ITaskContext context)
        {
            var compile = context
                .CreateTarget("compile")
                .SetDescription("Compiles the VS solution")
                .AddCoreTask(x => x.ExecuteDotnetTask(StandardDotnetCommands.Restore).WithArguments("FlubuExample.sln"))
                .AddCoreTask(x => x.Build("FlubuExample.sln"));
    
           context
                .CreateTarget("Package")
                .CoreTaskExtensions()
                .DotnetPublish("FlubuExample.sln");
    
            var test = context.CreateTarget("test")
                .AddCoreTaskAsync(x => x.Test().WorkingFolder("FlubuExample.Tests"))
                .AddCoreTaskAsync(x => x.Test().WorkingFolder("FlubuExample.Tests2"));
    
            context.CreateTarget("Rebuild")
                .SetAsDefault()
                .DependsOn(compile, test);
        }
    

    您可以在此处找到有关 Flubu 以及如何开始使用的更多信息: choice-for-build-tool-msbuild-nant-or-something-else

    【讨论】:

      【解决方案2】:

      为什么不直接调用 .NET CLI?我不太了解 TeamCity 或 Octopus,但在 Jenkins 或 AppVeyor 中,我能够执行批处理或 PowerShell 脚本。我使用它直接运行 .NET CLI 命令。 有了这个,您就不再依赖于任何预构建但过时的插件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-02-14
        • 1970-01-01
        • 2010-11-13
        • 1970-01-01
        • 2019-01-14
        • 1970-01-01
        • 2017-03-18
        • 1970-01-01
        相关资源
        最近更新 更多