VS2008 - 用于调试/发布配置输出不同的文件名 [英] VS2008 - Outputting a different file name for Debug/Release configurations

查看:153
本文介绍了VS2008 - 用于调试/发布配置输出不同的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建一个C#应用程序使用Visual Studio 2008,是不是可以设置每个配置不同的输出文件名?

When building a C# application with Visual Studio 2008, is it possible to set a different output filename per configuration?

e.g.

MyApp_Debug.exe
MyApp_Release.exe

我试过后生成步骤通过附加当前配置文件重命名,但似乎好斗的做法。加上它意味着Visual Studio中再也找不到该文件时pressing F5开始调试。

I tried a post-build step to rename the file by appending the current configuration, but that seems a scrappy approach. Plus it meant that Visual Studio could no longer find the file when pressing F5 to start debugging.

推荐答案

您可以通过手动编辑您的项目文件实现这一目标。找到<的AssemblyName> 节点,然后添加一个条件属性吧:

You can achieve this by editing your project file by hand. Locate the <AssemblyName> node and add a conditional attribute to it:

<AssemblyName Condition="'$(Configuration)'=='Debug'">MyApp_Debug.exe</AssemblyName>
<AssemblyName Condition="'$(Configuration)'=='Release'">MyApp_Release.exe</AssemblyName>

您将不得不重复它也添加其他条件属性的发行版本。

You'll have to duplicate it also to add another conditional attribute for the release version.

虽然是可能的,它可能会导致问题。有一个<一个href="http://msdn.microsoft.com/en-us/library/system.reflection.assemblyconfigurationattribute%28VS.80%29.aspx">AssemblyConfiguration可以应用到您的程序集的属性。在的AssemblyInfo.cs ,把:

Whilst it is possible, it may cause problems. There is an AssemblyConfiguration attribute that can be applied to your assembly. In AssemblyInfo.cs, put:

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

这将属性添加到您编译的程序集,将告诉你哪些构建配置您的应用程序使用内置。

This will add a property to your compiled assembly that will tell you which build configuration your application was built using.

这篇关于VS2008 - 用于调试/发布配置输出不同的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆