Visual Studio builds debug configuration, but not release configuration - visual-studio

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.

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.

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

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 Project → Properties → set Tool Settings to Release Mode and check the checkbox Suppress ICE validation.

Related

UWP package creation Error info: Packaname different

I have an issue updating my UWP app on Windows store. The issue is on the level of Visual studio (for windows). The description of the issue is the following:
Error info: error 80080204: The package with file name "MyApp_VersionNumber_x64.msix" and package full name "PackageName_VersionNumber_x64__Suffix" is not valid in the bundle because it has a different package family name than other packages in the bundle. The expected publisher is CN=PublisherName. AppName Prefix_Path\AppName\MakeAppx
The context is the following:
I update the app source code, then I associated the app in the store with the one updated.
In the windows related to the Application packages creation:
a. I choosed the distribute the application in windows store
b. Next, I choosed to always generate the application bath. (When I choose not to generate, it is impossible to publish the update because appxbundle is missing)
c. I selected the build x86, x64 and ARM like I did before
d. Finally I launch the creation to get the error above.
I followed multiple possible answer but nothing works.
Can someone helps me to overcome this issue?
Regards.
I had the same problem, the fix is a bit annoying, but for me it worked:
Close Visual Studio, go into your fileexplorer and open up the Folder with your project. Inside it you should find the "projectname.csproj" file. Open it up in your favorite texteditor and now follow the steps below:
1: Look for this line and also make sure it is the line with 'Release' and not 'Debug' in it:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
2: Inside the PropertyGroup tags you will find this line:
The value can either be true or false. If it is false, change it to true
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
Now repeate these steps for all four Release configurations and ONLY Release not Debug:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
After this, save the file and reopen Visual Studio. It now should create the package.

Create a new configuration for Visual Studio Project from command line

I want to create a configuration for a Visual Studio projectfrom command line in order to automate my release process. Typically you would go into Visual Studio, create a new configuration, select in the dropdown menu which build to copy from (in my case, this would be Release) and select the platforms. I want to do the same from command line.
I have tried the following:
MSBuild <mysolution>.sln -p:Configuration=<newconfigname>
But I get MSB4126 error, telling me that the configuration is not valid. I have also read the documentation on MSBuild, but it does not say anything about this. I am not even sure that this can be achieved using MSBuild. I am using Wix Installer in order to compile a .msi, and that works flawlessly, but it's building the Release configuration, instead of the one I want to build (custom release).
Can anyone shed some light on this issue?
I solved it by modifying some files.
You need to modify your .sln file to add your release type:
NewRelease|Any CPU = NewRelease|Any CPU
NewRelease|ARM = NewRelease|ARM
NewRelease|x64 = NewRelease|x64
NewRelease|x86 = NewRelease|x86
If you have submodules, add them as well. Create a new configuration in Visual Studio if you have doubts of what you need to add, and copy-paste from the configuration you created with Visual Studio, changing just the name of the configuration where needed.
You need to modify your .csproj file of the main project (not the WixInstaller one), for example:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NewRelease|AnyCPU'">
<OutputPath>bin\NewRelease\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
And, then again, if you have submodules, you have to modify every .csproj file to include your new release (copy from the other releases).
Finally, compile it with:
MSBuild <yourmainproject>.csproj -p:Configuration=NewRelease.

Visual Studio 2019 hangs when opening a solution with a dual targeted dotnet core and net framework project converted by hand

A developer migrated a csproj file to the newer csproj syntax. The top of the csproj file follows:
<Project DefaultTargets="Build" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4CF6CFA6-13B2-426E-913B-A42BF6642A69}</ProjectGuid>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
Other developers were no longer able to open the two solution files containing this project. Visual studio would begin opening the solution, but the progress bar would hang when it got to this converted project. It should be noted that many other projects had been migrated without this issue.
A blank solution was created and the hanging project was added to this blank solution. This opened without a hang.
Any ideas on what could be done to allow this project to not hang. I suppose a new project could be created as a work around.
I was able to correct the hang by creating a new project GUID and replacing the old project GUID in the csproj and sln files. This allowed the solution to open. I used the Visual Studio GUID tool available in the Visual Studio Tools main menu to create the GUID in registry format.

Xamarin Forms - debug prism module

Hy,
i have a Xamarin Prism application basically created with the PRISM Template Pack.
My modules are separated dlls.
I want to debug the modules code. So i add the source page in my shell applications visual studio window and set breakpoints.
When i run my application and open Debug-Window-Module dialog, i can see that my module status is "symbols loaded in VM".
So everything looks fine to me.
BUT the debugger doesn´t stop on my breakpoints.
Can anyone tell me what i can do to have debugging?
Thanks
Check out the solution submitted by #Breeze Liu - MSFT for this similar post.
It is possible that you need to edit the .csproj file of the shared project to include the following:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>Full</DebugType>
</PropertyGroup>

Visual Studio 2010 builds Console Application only in x86 target

I assume that many would mark this question as duplicate, but let me explain what kind of problem I'm facing right now.
I've just noticed that Console Application in solution has x86 target option, though everything else, e.g. libraries and dependent web site has AnyCPU target.
I've googled other question regarging Configuration Manager and adding new configuration AnyCPU for my Console Application, but here is the problem. I can't create new AnyCPU configuration as I get error, that it's already created:
And here is error creating new configuration with AnyCPU target:
I just don't get it why I can't create this configuration, it isn't listed in dropdown selector for my project.
There is another place where target configuration might be changed, it's project properties' build tab:
and I've set AnyCPU value in platform target, but platform is still x86.
The only way to change platform itself is editing csproj directly:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
And here we come to my questions:
What's the idea to place target property in two different properties?
Why can't I select AnyCPU for console applications by default? There was opinion that Visual Studio team made this intentionally.
And what possible issues might occur if I change target platform by editing csproj file?

Resources