PublishRelease=true in project file doesn't actually change the configuration to "Release" when running "dotnet publish"
See original GitHub issueRE #23551
Trying out <PublishRelease>true</PublishRelease>
in a console project and it seems if I also set <PublishAot>true</PublishAot>
then a debug build is performed rather than a release build.
HelloWorld.Console.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishRelease>true</PublishRelease>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
Run dotnet publish HelloWorld.Console -r win-x64 --self-contained -v -o .artifacts\HelloWorld.Console
Output:
Publishing HelloWorld.Console: dotnet publish -r win10-x64 --self-contained
Determining projects to restore...
Restored ~\HelloWorld.Console\HelloWorld.Console.csproj (in 72 ms).
C:\Program Files\dotnet\sdk\7.0.100-rc.1.22368.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(219
,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [~\HelloWorld.Console\HelloWorld.Console.csproj]
HelloWorld.Console -> ~\HelloWorld.Console\bin\Debug\net7.0\win10-x64\HelloWorld.Console
.dll
Generating compatible native code. To optimize for size or speed, visit https://aka.ms/OptimizeNativeAOT
Creating library bin\Debug\net7.0\win10-x64\native\HelloWorld.Console.lib and object bin\Debug\net7.0\win10-x64\native\HelloWorld.Console.exp
HelloWorld.Console -> ~\.artifacts\HelloWorld.Console\
dotnet --info
.NET SDK:
Version: 7.0.100-rc.1.22368.2
Commit: a9c056cd39
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100-rc.1.22368.2\
Host:
Version: 7.0.0-rc.1.22366.5
Architecture: x64
Commit: 072eda8d6b
.NET SDKs installed:
6.0.302 [C:\Program Files\dotnet\sdk]
6.0.400-preview.22330.6 [C:\Program Files\dotnet\sdk]
7.0.100-rc.1.22368.2 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.1.22367.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-preview.5.22301.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.1.22366.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-preview.5.22302.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.1.22366.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
Environment variables:
Not set
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Issue Analytics
- State:
- Created a year ago
- Comments:27 (26 by maintainers)
Top Results From Across the Web
Set configuration to "Release" when publishing
Create batch/powershell file for the command dotnet publish -c Release. save it into release.cmd and run that when needed.
Read more >'dotnet publish' uses Release configuration - .NET
Learn about a breaking change in the .NET 8 SDK where 'dotnet publish' uses the 'Release' configuration by default.
Read more >'dotnet pack' uses Release configuration - .NET
Learn about a breaking change in the .NET 8 SDK where 'dotnet pack' uses the 'Release' configuration by default.
Read more >MSBuild reference for .NET SDK projects
This property is useful if you run dotnet publish on a solution file, as it allows automatic selection of projects that should be...
Read more >Set debug and release configurations in Visual Studio
Visual Studio projects have separate release and debug configurations for your program. You build the debug version for debugging and the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aug 12 is the code-complete date for rc.1 so if we want it in rc.1 then I’d assume that’s the date the change is needed in main by.
Chiming in with a bit of context: We saw that the value of
Configuration
(very early on) determines the values ofOptimize
andDebugSymbols
. Thankfully,Optimize
andDebugSymbols
aren’t really used untilCsc
is called. From there we concluded that we can add a condition in the sdk’s publish targets that set the two properties to what they should be under aRelease
configuration, and this would happen well before csc would be called.