将默认的生成配置添加到Visual Studio [英] Add default build configuration to Visual Studio
问题描述
我和我的团队正在将VS2012用于许多项目,并与我们的QA和UAT组一起开发了涉及5种环境的工作流:本地,开发阶段,测试,预生产和生产。我们发现自己必须为每个项目和解决方案创建Local / Dev / Test / Preprod / Prod构建配置,并删除调试和发布配置。
My team and I are using VS2012 for a number of projects, and have developed a workflow with our QA and UAT group that involves 5 environments: Local, Development Staging, Testing, Preproduction, and Production. We've found ourselves having to create Local/Dev/Test/Preprod/Prod build configuration for every project and solution, and remove the debug and release configurations.
有什么方法可以让VS在默认情况下在新项目上创建这些环境,而不是在调试/发布配置中创建?
Is there any way to have VS create these environments by default on new projects instead of the debug/release configurations?
编辑:
我找不到任何全局选项,似乎构建配置都位于单个项目文件夹中。
I've not been able to find any Global option for this, as it seems the build configurations are all in the individual project folders.
我所做的就是找到一些我最常用的项目并进行了修改因此,项目模板如下:
What I've done is find some of my most common projects and modified the project templates thusly:
- 修改.csproj文件并用以下内容替换PropertyGroups:
- Modify the .csproj file and replace PropertyGroups with the following:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Local|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<-- SNIP -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Prod|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Content Include="Web.config" />
<Content Include="Web.Local.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Dev.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Test.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Preprod.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Prod.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<ProjectItem ReplaceParameters="true" TargetFileName="Web.config">WebApiWeb.config</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Web.Local.config">Web.Local.config</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Web.Dev.config">Web.Dev.config</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Web.Test.config">Web.Test.config</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Web.Preprod.config">Web.Preprod.config</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Web.Prod.config">Web.Prod.config</ProjectItem>
当我创建新项目时,所有需要的环境都在那里,并且调试消失了!但是,Release仍然存在,包括我删除的web.Release.Config文件。知道这个无关的配置文件/构建配置可能来自哪里吗?
When I create the new projects, all of my desired environments are there, and debug is gone! However, Release is still there, including the web.Release.Config file, which I deleted. Any idea where this extraneous config file/build configuration may be coming from?
推荐答案
是,创建一个自定义项目模板。如果这还不够,您甚至可以创建自定义项目类型,但是,其中涉及更多。
Yes, create a custom project template. If this does not suffice, you can even create a custom project type, which is a bit more involved, however.
这篇关于将默认的生成配置添加到Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!