如何在 ASP.NET Core 中基于解决方案配置运行脚本 [英] How to run scripts based on solution configuration in ASP.NET Core

查看:10
本文介绍了如何在 ASP.NET Core 中基于解决方案配置运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 project.json 文件中有以下脚本,用于将我的类库项目构建到 NuGet 包中.我不想构建任何调试 NuGet 包.如何限制此脚本仅在解决方案配置设置为发布模式时运行,以加快调试模式下的构建时间?

I have the following script in my project.json file which I am using to build my class library project into a NuGet package. I don't want to build any Debug NuGet packages. How can I limit this script to only run when the solution configuration is set to Release mode to speed up the build time in debug mode?

或者,出于好奇,我如何将解决方案配置传递到下面的命令中,这样发布"就不会被硬编码.

Alternatively, as a matter of curiosity, how can I pass the solution configuration into the command below so that 'Release' is not hard coded.

"scripts": {
  "postcompile": [
    "dotnet pack --no-build --configuration Release"
  ]
}

推荐答案

你可以使用%compile:Configuration%来获取当前的Configuration.这里是变量列表可用于 precompilepostcompile 脚本.

You can use %compile:Configuration% to get the current Configuration. Here is the list of variables available to precompile and postcompile scripts.

这篇关于如何在 ASP.NET Core 中基于解决方案配置运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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