visual-studio - 根据新 ASP.NET 5 项目中的配置名称发布构建事件

标签 visual-studio asp.net-core post-build-event buildconfiguration

我正在为 3 台智能电视编写一个统一的项目。我还在 Visual Studio 中创建了 3 个配置.现在我想执行一些 CLI脚本取决于所选的配置。

问题出在新 ASP.NET 5项目我没有用于后期构建事件的编辑器。

我知道我必须在 project.json 中执行此操作.我发现的是:

  "scripts": {
    "postbuild": ""
  }

但是使用这个我无法创建不同的 CLI不同配置的脚本。

我还发现:
  "configurations": {
  },

我想这可能就是我想要的,但是...如何使用它?智能感知在这里没有力量,而且我也没有幸运地在网上搜索......

[编辑]

也许我应该试试 .xproj ?

最佳答案

您需要构建一个主脚本,该脚本使用可用的上下文和环境变量来切换和运行您选择的其他脚本。

除了变量列表Here编译时,你还会得到 these用于发布相关脚本然后these随处可用,由 Environment.GetEnvironmentVariable 返回的环境变量也是如此。 ,可见here .

下图显示了来自 VS2015 Update 3 RTM 的智能感知,但它具有误导性,因为您根据正在使用的脚本块获得其他智能感知:

enter image description here

因此,可用于控制脚本中的流程的上下文变量的完整列表是:

每个脚本块:

  • %project:目录%
  • %project:姓名%
  • %project:Version%

  • 具体编译:
  • %compile:TargetFramework%
  • %compile:FullTargetFramework%
  • %编译:配置%
  • %compile:OutputFile%
  • %compile:OutputDir%
  • %compile:ResponseFile%
  • %compile:RuntimeOutputDir%(仅在有运行时输出时可用)
  • %compile:RuntimeIdentifier%(只有在有运行时输出时才可用)
  • %comiple:CompilerExitCode%(仅在后编译脚本块中可用)

  • 具体发布:
  • %publish:ProjectPath%
  • %publish:配置%
  • %publish:OutputPath%
  • %publish:TargetFramework%
  • %publish:FullTargetFramework%
  • %publish:运行时%
  • 关于visual-studio - 根据新 ASP.NET 5 项目中的配置名称发布构建事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35287635/

    相关文章:

    c# - c#中的断点

    c# - 模型中具有继承的 ASP Core 标记帮助器

    c# - _userManager.GetUserAsync(User) 返回 null

    tfs - 我们在哪里可以打开构建过程模板的 `Post-build script`框?

    c# - Visual Studio 2017 在打开后停止工作并显示许多控制台窗口

    c++ - 在不强制转换的情况下混合索引和指针算法时避免 C4365

    c# - 删除按钮 SQL 数据库 Windows 窗体应用程序

    c# - asp.net core 操作中参数的映射命名约定

    visual-studio-2010 - 如何在 Visual Studio 后期生成事件中使用 msbuild?

    c# - 使用外部 EXE 作为启动项目