views:

1615

answers:

3

SUMMARY: How to compile in Release mode...I cannot get it to "take" what I want to do.

I have a webservice project in VS2005 C# that I am trying to optimize. One of the things I've had my awareness raised on is the recommendation to compile in Release mode. I am not sure what to expect here but here is what I am seeing:

I rightmouse on the project and choose Properties and then the Build tab I click the Configuration dropdown box, set to RELEASE and notice that Output Path is \bin I click REBUILD on the project and the DLL goes into the \bin\debug folder (not \bin)! Here is a snippet pasted from the output window on that compile (note it shows the configuration as "Debug Any CPU" and later /define:DEBUG;TRACE):

------ Rebuild All started: Project: TRIMBrokerService, Configuration: Debug Any CPU ------
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE 
/reference:"C:\Program Files\Microsoft WSE\v3.0\Microsoft.Web.Services3.dll" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll 
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:..\TRIMBrokerUtilities\TRIMBrokerUtil\bin\Debug\TRIMBrokerUtil.dll 
/debug+ /debug:full /optimize- /out:obj\Debug\TRIMBrokerService.dll /target:library FaultCode.cs FileService.asmx.cs Properties\AssemblyInfo.cs Properties\Settings.Designer.cs Settings.cs "Web References\ASMXwsTrim\Reference.cs"

Compile complete -- 0 errors, 0 warnings
TRIMBrokerService -> C:\Documents and Settings\johna\My Documents\Visual Studio 2005\Projects\WSE\TRIMBrokerPassingByteArray\TRIMBroker\TRIMBrokerService\bin\debug\TRIMBrokerService.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

I've noticed that I can interact with the Build tab dialog and when I change the Configuration dropdown list box to Active(Debug) or just Debug then the Output Path changes to \bin\debug as one would expect but I cannot seem to get it to compile in Release mode. Is there a trick? I dread having to read up on the MSBuild documentation just to deploy my little web service as I think it is way more than I need at this point.

+1  A: 

If you've got the assembly going to bin\Debug ever, then someone has modified the project the wrong way. Anything using ASP.NET needs to have the assemblies go to bin.

John Saunders
Thanks..I thought something was wrong. Ryan's approach at the Solution level seemed to fix everything.
John Galt
When is the bin\debug folder used by the Build or Rebuild compile action? I believe I've seen the .DLLs go there in the past and not paid much attention to it. I reasoned that (incorrectly I see) that the bin would contain the Release mode build(s) and the bin\debug would contain the Debug build(s). Since that is not correct and everything always needs to go to bin\, what is the best way to keep straight how a given .DLL was compiled?
John Galt
For ASP.NET-based projects, there is only bin. Most others will likely have a bin\<configuration> folder. For the ASP.NET projects, IIS can only have a single folder to look in for assemblies - IIS won't know if this is a Release or Debug build.
John Saunders
Thanks John. This is finally starting to make sense as I encountered this very behavior today. So I will be researching "best practices" for keeping track of what is in bin\ for web projects (i.e. was it compiled as Debug or as Release); hard to know I think whereas other project types will apparently have the subfolder within bin named to reflect the build type.
John Galt
+3  A: 

Right-click on your solution and choose Configuration Manager.. Make sure "Active solution configuration" is set to Release. Then make sure the project(s) in the grid below are set to use the Release configuration.

Perhaps something was changed accidentally..

Ryan Emerle
Thanks Ryan. I did as you said and it fixed the problem.
John Galt
A: 

In addition to Ryan's response, the configuration set on the Build tab of the project settings has no effect on the current build mode, this just allows you to modify the settings for this project on each configured build mode in one easy place.

You can also use the "Solution Configurations" dropdown on the default "Standard" toolbar that lists the solution configurations next to the "Debug" button and the "Solution Platforms" dropdown.

Zhaph - Ben Duguid