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

I am writing a unified project for 3 smart TVs. I also have 3 configurations created in Visual Studio . Now I want to execute some CLI scripts depending on the selected configuration.

Problem in a new ASP.NET 5 project. I do not have a post build event editor.

I know that I have to do this in project.json . I found:

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

But with this, I cannot create different CLI scripts for different configurations.

I also found:

  "configurations": { }, 

And I think this is probably what I want, but ... How to use it? Intellisense has no power here, and also I was not lucky to find on the Internet ...

[edit]

Maybe I should try .xproj ?

+6
source share
2 answers

You will need to create a script wizard that uses the available context and environment variables to switch and run other scripts of your choice.

In addition to the list of variables, here for compilation you also get these for publishing related scripts and then these are available everywhere, as well as the environment variables returned by Environment.GetEnvironmentVariable , which can be seen here .,

The figure below shows the intellisense from RTM version 3 of the updated VS2015 software, but it is misleading since you get others depending on the script block you use:

enter image description here

So, your complete list of context variables that you can use to control the flow in your scripts:

Each script block:

  • % of the project: Reference%
  • % of project: Name%
  • % of the project: Version%

Compilation specification:

  • % compilation: TargetFramework%
  • % compilation: FullTargetFramework%
  • % compilation:% configuration
  • % compilation: OutputFile%
  • % compilation: OutputDir%
  • % compilation: ResponseFile%
  • % compile: RuntimeOutputDir% (only available with runtime)
  • % compile: RuntimeIdentifier% (only available with runtime)
  • % comiple: CompilerExitCode% (only available in postcompile script block)

Post specific:

  • % publish: ProjectPath%
  • % publish: Configuration%
  • % publish: OutputPath%
  • % publish: TargetFramework%
  • % publish: FullTargetFramework%
  • % publish: runtime%
+13
source

I investigated this a bit, but actually did not get any good result.

There are some project variables that appear in scripts. Unfortunately, they are very limited :

  • %project:Name% gives the project name
  • %project:Directory% provides the project directory
  • %project:Version% gives you the project version

Thus, there is no way to access the assembly configuration or environment.

The configurations option in project.json also limited to building configurations and only allows the declaration of compilation options, and therefore also does not work.

Unfortunately, there is also no other way to solve this problem. At least for now. I would think that I am sending a DNX porting request to add some additional project variables that could be used, but at the moment it makes no sense to invest time in DNX: after everything has been replaced with CLET dotnet. Well, let's see if this has a functionality function for accessing the environment, and if not, I can send a transfer request to add this functionality. But until we get there, I'm afraid there is no solution for this.

+5
source

All Articles