根据新ASP.NET 5项目中的配置名称发布构建事件 [英] Post build event depending on configuration name in new ASP.NET 5 project
问题描述
我正在为3台智能电视编写一个统一的项目。我还在 Visual Studio
中创建了3种配置。现在,我要根据所选配置执行一些 CLI
脚本。
问题出在新的 ASP.NET 5
项目我没有后期构建事件的编辑器。
我知道我必须在 project.json
。我发现的是:
脚本:{
postbuild:
}
但是使用此我无法创建其他 CLI
用于不同配置的脚本。
我还发现:
配置:{
},
我想这可能是我想要的,但是...如何使用? Intellisense在这里无能为力,而且我也不幸运在网上搜索...
[edit]
也许我应该尝试使用 .xproj
?
您需要构建一个主脚本,该脚本使用可用的上下文和环境变量来切换和运行您选择的其他脚本。
变量
因此,您可以使用上下文变量的完整列表来控制脚本中的流程是:
每个脚本块:
- %project:Directory%
- %project:Name%
- %project:Version%
特定于编译:
- %compile:TargetFramework%
- %compile:FullTargetFramework%
- %compile:Configuration%
- %compile:OutputFile%
- %compile:OutputDir%
- %compile:ResponseFile%
- %compile:RuntimeOutputDir%(仅在有运行时输出时可用)
- %编译:RuntimeIdentifier %(仅当有运行时输出时可用)
- %comiple:CompilerExitCode%(仅在后编译脚本块中可用)
特定于发布:
- %publish:ProjectPath%
- % publish:配置%
- %publish:OutputPath%
- %publish:TargetFramework%
- %publish: FullTargetFramework%
- %publish:Runtime%
I'm writing a unified project for 3 smart TVs. I have also 3 configurations created in Visual Studio
. Now I want to execute some CLI
scripts depending on selected configuration.
The problem is in new ASP.NET 5
project I don't have an editor for post build events.
I know I have to do this in project.json
. What I found is:
"scripts": {
"postbuild": ""
}
But using this one I can't create different CLI
scripts for different configurations.
I found also:
"configurations": {
},
And I guess this is probably what I want, but... How to use it? Intellisense has no power here and also I wasn't lucky searching the Web...
[edit]
Maybe I should try with .xproj
?
You'll need to build a master script which uses the available context and environment variables to switch and run the other scripts of your choice.
In addition to the list of variables Here for compile, you also get these for publish related scripts and then these are available everywhere, as are environment variables returned by Environment.GetEnvironmentVariable
, which can be seen here.
The image below shows the intellisense from the VS2015 Update 3 RTM, but it's misleading, since you get others depending on the script block you're using:
So, your full list of context variables that you can use to control flow in your scripts is:
Every script block:
- %project:Directory%
- %project:Name%
- %project:Version%
Compile specific:
- %compile:TargetFramework%
- %compile:FullTargetFramework%
- %compile:Configuration%
- %compile:OutputFile%
- %compile:OutputDir%
- %compile:ResponseFile%
- %compile:RuntimeOutputDir% (only available if there is runtime output)
- %compile:RuntimeIdentifier% (only availabe if there is runtime output)
- %comiple:CompilerExitCode% (only available in the postcompile script block)
Publish specific:
- %publish:ProjectPath%
- %publish:Configuration%
- %publish:OutputPath%
- %publish:TargetFramework%
- %publish:FullTargetFramework%
- %publish:Runtime%
这篇关于根据新ASP.NET 5项目中的配置名称发布构建事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!