Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
836 views
in Technique[技术] by (71.8m points)

visual studio - Post build event depending on configuration name in new ASP.NET 5 project

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

enter image description here

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%

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...