c# - How to use different Application Settings for different build configurations? -


At the top of the application-tab (red) of project properties, there are 2 graded dropdown boxes (green),

which I use Would like to

project properties

i output based on existing build configuration Want to change the type. To use the console for debug output, when I want to make an debug-build project to be a console app when I release-build I should have this project a Windows application .

How can I enable a grade out box?

Note : This is a C # -app

You can not apply Visual Studio to enable options, but you can manually get effects by editing the csproj file. MSBuild is really powerful and the Visual Studio goes to hide its functionality so that it's easy for basic use cases. To edit the Csproj file, right-click on the project and select the Load Project, right-click and select Edit. A standard CSPORG for the console app will appear at the top such a way

   & Lt; PropertyGroup & gt; & Lt; Configuration Status = "'$ (Configuration)' == ''" & gt; Debug & lt; / Configuration & gt; & Lt; Platform Status = "'$ (Platform)' == ''" "& gt; AnyCPU & lt; / Platform & gt; & Lt; ProjectGuid & gt; {DE6C0E52-0B46-42E1-BA10-83C0B7B08A7F} & lt; / ProjectGuid & gt; & Lt; OutputType & gt; Exe & lt; / OutputType & gt; & Lt; AppDesignerFolder & gt; Properties & lt; / AppDesignerFolder & gt; & Lt; RootNamespace & gt; ServiceSample & lt; / RootNamespace & gt; & Lt; AssemblyName & gt; ServiceSample & lt; / AssemblyName & gt; & Lt; TargetFrameworkVersion & gt; V4.5 & lt; / TargetFrameworkVersion & gt; & Lt; FileAlignment & gt; 512 & lt; / FileAlignment & gt; & Lt; / PropertyGroup & gt;   

Type the element output Note that this is what we want to change. Value "corresponds to the Exe" console application, while "Wainksa" corresponds to any Windows application in Visual Studio UI. There are some ways to do this, but the simplest possible is with it. The edit this section to look like:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Project Tools version = "12.0" default target = "Build" xmlns = "http://schemas.microsoft.com/developer/msbuild/2003" & gt; & Lt; Import Project = "$ (MSBuildExtensionsPath) \ $ (MSBuildToolsVersion) \ Microsoft.Common.props" status = "exists ( '$ (MSBuildExtensionsPath) \ $ (MSBuildToolsVersion) \ Microsoft.Common.props')" / & gt; & Lt; PropertyGroup & gt; & Lt; Configuration Status = "'$ (Configuration)' == ''" & gt; Debug & lt; / Configuration & gt; & Lt; Platform Status = "'$ (Platform)' == ''" "& gt; AnyCPU & lt; / Platform & gt; & Lt; ProjectGuid & gt; {DE6C0E52-0B46-42E1-BA10-83C0B7B08A7F} & lt; / ProjectGuid & gt; & Lt; -! & Lt; OutputType & gt; Exe & lt; / OutputType & gt; - & gt; & Lt; AppDesignerFolder & gt; Properties & lt; / AppDesignerFolder & gt; & Lt; RootNamespace & gt; ServiceSample & lt; / RootNamespace & gt; & Lt; AssemblyName & gt; ServiceSample & lt; / AssemblyName & gt; & Lt; TargetFrameworkVersion & gt; V4.5 & lt; / TargetFrameworkVersion & gt; & Lt; FileAlignment & gt; 512 & lt; / FileAlignment & gt; & Lt; / PropertyGroup & gt; & Lt; Select & gt; & Lt; When condition = "'$ (configuration)' == 'debug'" & gt; & Lt; PropertyGroup & gt; & Lt; OutputType & gt; Exe & lt; / OutputType & gt; & Lt; / PropertyGroup & gt; & Lt; / When & gt; & Lt; Otherwise & gt; & Lt; PropertyGroup & gt; & Lt; OutputType & gt; Winexe & lt; / OutputType & gt; & Lt; / PropertyGroup & gt; & Lt; / Otherwise & gt; & Lt; / Select & gt;   

Note that we have commented on the main communication group output type and choose to put the sections in the element, which will select the values ​​based on the value of the configuration property.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -