Visual Studio builds debug configuration, but not release configuration

19,769

Solution 1

OK, if anyone else has the same problem, here is what I did. Thanks to Dylan Smith, I got to the solution.

Open your .csproj file with a text editor of your choice. I used Notepad++, but Visual Studio is also working. At the top there should be elements called PropertyGroup. Those elements define your build configurations. For me there were two:

One for Debug:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <PlatformTarget>x86</PlatformTarget>
        <DocumentationFile>bin\Debug\GW2.NET.XML</DocumentationFile>
    </PropertyGroup>

And one for Release:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>none</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <DocumentationFile>bin\Release\GW2.NET.XML</DocumentationFile>
        <LangVersion>4</LangVersion>
        <PlatformTarget>x86</PlatformTarget>
    </PropertyGroup>

Apart from the obvious differences, with the first two nodes (DebugSymbols and DebugType), the main difference was the LangVersion element. I deleted it and voilà the project builds in release mode too.

So if you have the same problem as me, open the .csproj file and delete this node. This should solve it.

P.S.: What does the LangVersion element mean? If I change it from 4 to, say, 4.0, I get the following error:

Invalid option '4.0' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

Solution 2

If you are really stuck, one thing you could do is open up the .csproj file in a text or XML editor and inspect the actual XML content in there. You're trying to figure out what settings/properties are set differently based on Debug/Release configurations. This might give you some insight into what it is doing different between the two configurations.

Solution 3

If you are building a WiX setup project using Visual Studio 2010 with your own custom dialog boxes and your project builds in debug mode, but not in release mode, then go to menu ProjectProperties → set Tool Settings to Release Mode and check the checkbox Suppress ICE validation.

Share:
19,769
Ruhrpottpatriot
Author by

Ruhrpottpatriot

Currently coordinator and developer on the Open-Source GW2 API wrapper GW2.NET Which can be found on Codeplex or at the official GW2 Forums

Updated on June 15, 2022

Comments

  • Ruhrpottpatriot
    Ruhrpottpatriot almost 2 years

    This particular problem is a big one.

    In my current configuration Visual Studio 2013 builds my project if it is in Debug configuration, but not if it is in Release configuration.

    Somehow when I select Release, 160 errors pup up and when I go through them they are in impossible places. Here is one example.

    Visual studios Error is the following:

    Error 3 ; expected E:\Users\Robert\Documents\Visual Studio 2013\Projects\GW2.NET\GW2.NET\GW2.NET\V1\MapInformation\DataProvider\ContinentData.cs 96 36 GW2.NET

    And here is the code in question:

    public static async Task<T> GetContentAsync<T>(string apiMethod, List<KeyValuePair<string, object>> arguments, Categories category)
        {
            var response = await GetJsonAsync(apiMethod, arguments, category);
    
            return await Task.Factory.StartNew(() => JsonConvert.DeserializeObject<T>(response));
        }
    

    You see there isn't any error. If there were one, the Debug configuration wouldn't build either. I already tried to clean the solution and got the latest from TFS, and I deleted and recreated the configurations.

    For now I am at my wit's end. How can I fix this?

    The project is a C# 4.0 project with the Microsoft async, JSON.NET, and Rest# packages.