Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run scripts based on solution configuration in ASP.NET Core

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"
  ]
}
like image 611
Muhammad Rehan Saeed Avatar asked Jun 02 '16 15:06

Muhammad Rehan Saeed


1 Answers

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

like image 83
Pawel Avatar answered Oct 08 '22 20:10

Pawel