Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. What's the difference between dotnet publish -c Release vs -c Debug?

What's the difference between dotnet publish -c Release vs -c Debug?

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpvisual-studioc++asp-netdebugging
5 Posts 2 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DeltaOrionis
    wrote on last edited by
    #1

    Hi everyone, I'm building my personal web site using ASP.Net and recently noticed something curious. When publishing my project, it doesn't seem to matter if I use:

    dotnet publish -c Release -o out

    or

    dotnet publish -c Debug -o out

    Both commands will output (as far as I can tell) exactly the same binary. However shouldn't the release output be smaller/optimized? Unfortunately I can't find much documentation regarding this config flag and as far as I can tell, the dotnet command is just passing it along to MSBuild which then select the proper configuration (profile?). Does anyone know if it's supposed to work like that or am I doing something dumb? PS: My csproj has nothing special in it as far as I can tell:

    	net6.0
    	enable
    
    
    
    	
    	
    	
    	
    	
    	
    	
    	
    		all
    		runtime; build; native; contentfiles; analyzers; buildtransitive
    
    D 1 Reply Last reply
    0
    • D DeltaOrionis

      Hi everyone, I'm building my personal web site using ASP.Net and recently noticed something curious. When publishing my project, it doesn't seem to matter if I use:

      dotnet publish -c Release -o out

      or

      dotnet publish -c Debug -o out

      Both commands will output (as far as I can tell) exactly the same binary. However shouldn't the release output be smaller/optimized? Unfortunately I can't find much documentation regarding this config flag and as far as I can tell, the dotnet command is just passing it along to MSBuild which then select the proper configuration (profile?). Does anyone know if it's supposed to work like that or am I doing something dumb? PS: My csproj has nothing special in it as far as I can tell:

      	net6.0
      	enable
      
      
      
      	
      	
      	
      	
      	
      	
      	
      	
      		all
      		runtime; build; native; contentfiles; analyzers; buildtransitive
      
      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The output is MSIL, not machine code native to your CPU. That doesn't get generated until the code is loaded and running, call JIT Compiling. The code can be optimized for the CPU being used. Whether or not there are optimizations depends on how you've written your code and the CPU you run it on. Debug builds do not run with optimizations, but contain more debugging information that may not be in the final executables.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      D 1 Reply Last reply
      0
      • D Dave Kreskowiak

        The output is MSIL, not machine code native to your CPU. That doesn't get generated until the code is loaded and running, call JIT Compiling. The code can be optimized for the CPU being used. Whether or not there are optimizations depends on how you've written your code and the CPU you run it on. Debug builds do not run with optimizations, but contain more debugging information that may not be in the final executables.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        D Offline
        D Offline
        DeltaOrionis
        wrote on last edited by
        #3

        Thanks but in that case I don't understand what is the purpose of the --configuration flag? I understand that JIT will optimize things at runtime but I was expecting the --configuration to, at least, do some sort of (even if small) optimization when compiling (a la gcc compiling C code for example) to MSIL. Many tutorials (especially Microsoft) almost always add that flag when publishing so it must do something but I can't understand what exactly.

        Quote:

        Debug builds do not run with optimizations, but contain more debugging information that may not be in the final executables.

        Yes this is exactly what I find confusing because my debug build doesn't have (as far as I can tell) any extra debugging information. It seems to be exactly the same as the release build (using -c Release)

        D 1 Reply Last reply
        0
        • D DeltaOrionis

          Thanks but in that case I don't understand what is the purpose of the --configuration flag? I understand that JIT will optimize things at runtime but I was expecting the --configuration to, at least, do some sort of (even if small) optimization when compiling (a la gcc compiling C code for example) to MSIL. Many tutorials (especially Microsoft) almost always add that flag when publishing so it must do something but I can't understand what exactly.

          Quote:

          Debug builds do not run with optimizations, but contain more debugging information that may not be in the final executables.

          Yes this is exactly what I find confusing because my debug build doesn't have (as far as I can tell) any extra debugging information. It seems to be exactly the same as the release build (using -c Release)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You're also assuming that your code has stuff to optimize.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          D 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You're also assuming that your code has stuff to optimize.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
            Dave Kreskowiak

            D Offline
            D Offline
            DeltaOrionis
            wrote on last edited by
            #5

            That's actually a very good point now that you mentioned it. I didn't consider that and assumed that an ASP.Net app would be large enough to see some optimizations but I guess the libraries used are already optimized and my code doesn't have much stuff to optimize.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups