I have several possible configurations in a Visual Studio project file. How can I specify which one is selected by default (when no .suo
is present)? Right now, when I open the project in Visual Studio, Debug configuration is selected by default.
Relevant part of the project file:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>...</ProductVersion>
<SchemaVersion>...</SchemaVersion>
<ProjectGuid>{...}</ProjectGuid>
<OutputType>...</OutputType>
<RootNamespace>...</RootNamespace>
<AssemblyName>AAAAA</AssemblyName>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>Full</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>false</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DocumentationFile>AAAAA.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\</OutputPath>
<DocumentationFile>AAAAA.xml</DocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
I want this configuration to be selected by default:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>Full</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>false</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DocumentationFile>AAAAA.xml</DocumentationFile>
</PropertyGroup>
A build configuration is a collection of settings used to start a build and group the sequence of the builds in the UI. Examples of build configurations are distribution, integration tests, prepare release distribution, "nightly" build. A build configuration belongs to a project and contains builds.
Create a project configurationSelect a project in the Project column. In the Configuration drop-down list for that project, choose New. The New Project Configuration dialog box opens. In the Name box, enter a name for the new configuration.
From the main menu, select Run | Edit Configurations. Alternatively, press Alt+Shift+F10 , then 0 . In the left-hand pane of the run/debug configuration dialog, click Edit configuration templates…. In the Run/Debug Configuration Templates dialog that opens, select a configuration type.
Visual Studio always invokes the build through a solution. Each solution configuration has a (case-insensitive) name and maps each project to its configuration. Solution configurations can be edited through Build > Configuration manager and the currently active one is selected there or in the drop-down in the toolbar.
Active build configuration is saved in solution user options file (.suo
). This is a per-user configuration and should not be checked in the source control. No shared configuration exists for this.
If no .suo
file is present, VS selects the configuration, whose name sorts alphabetically first with several exceptions:
E.g. if you have this list of configurations, "Debug all" is selected by default. If you remove the first configuration in the list, close VS and delete the *.suo
file, the next one on the list will be selected by default.
Debug all Debug Debugging A release ARelease Release WinterBash
Note that VS displays a different order:
A release ARelease Debug Debug all Debugging Release WinterBash
If you open a project file (e.g. MyProject.csproj
) directly, Visual Studio tries to locate a solution file.
MyProject.sln
) is preferred. If it is found, it is used.*.sln
) are searched. If exactly one is found, it is used...\*.sln
). If exactly one is found, it is used.MyProject.sln
) containing only the project and asks on exit where to save it. This new solution's build configurations correspond to the ones the project has.Note that this is probably going to be different in the upcoming VS 2017 as it supports even bare files without projects.
You can see the path to the solution as Path in Properties window. (Select the solution in Solution Explorer first.)
By the way, the first PropertyGroup
in a project file specifies the defaults to be used by MSBuild when Configuration
and Platform
properties are empty (unspecified). Visual Studio always specifies these properties, so the defaults are irrelevant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With