简体   繁体   中英

How to use VisualStudio build configuration to define DEBUG for dotnet Core project?

As far as I know, Debug.Assert will not work without "define": [ "DEBUG" ] in project.json. I want to have it on dev machine and strip out on build server. Should I just modify project.json as txt file after checkout on build server, or there is more elegant way?

PS. I know about "project.json in 2017".

You can define different options for different configurations in project.json . On your build server you can build the "Release" configuration.

{
  "configurations": {
    "Debug": {
      "buildOptions": {
        "define": ["DEBUG", "TRACE"]
      }
    },
    "Release": {
      "buildOptions": {
        "define": ["RELEASE", "TRACE"],
        "optimize": true
      }
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM