Visual Studio 扩展将输出文件重定向到指定文件夹
通常,Visual Studio 将输出文件放入 bin/debug 或 bin/release 中。
当解决方案包含大量项目时,手动修改每个项目输出并不容易。
在 csproj 文件中进行编辑也是不可取的,因为其中一些在解决方案之间共享。
我的问题:有人知道一个可以快速配置输出路径的工具吗?
更新:我的问题通过 TFS Build 解决了
Usually, visual studio puts output files to bin/debug or bin/release.
When solution contains a large number of projects its not easy to modify each project output manually.
Also edits in csproj files no desirable, because some of them is shared between solutions..
My questions: Is anybody knows a tool, which can quickly configure output path ?
UPDATE: my problem solved by TFS Build
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据推测,每个解决方案中至少有一个该解决方案所独有的项目。在生成后事件中,将每个项目的输出内容复制到所需位置。
我们经常使用批处理文件来实现这一点。这很粗糙但很有效。在我们的解决方案特有的项目中,我们创建了一个 Release.bat 文件。这包含许多文件副本,用于从其他项目的各个输出目录复制所有必需的组件。然后,您可以在构建后事件中运行批处理文件。当解决方案构建时,我们通常将所有内容复制到“最新版本”文件夹中。如果这成为正确的版本,我们会将最新版本文件夹重命名为实际版本号。
如果您有多个构建配置,或者甚至仅使用调试和发布配置,则可以在构建后事件中使用 If 语句来决定要运行哪个批处理文件。因此,您可以创建 Debug.bat、Release.bat 等来满足您的需要。一开始设置它们并让它们正常工作可能很乏味,但一旦完全实施,它们就非常有用。
Presumably you have at least one project in each solution that is unique to that solution. In the Post-Build event of that, copy the contents of each project's output to the required location.
We often to this using a batch file. It's crude but effective. In our project that's unique to the solution we create a Release.bat file. This contains a number of file copies to copy all of the required components from the various output directories of the other projects. You can then just run the batch file in the post build event. We usually copy everything to a "Latest Release" fodler when the solution is built. If this becomes a proper release we will rename the Latest Release folder to the actual release number.
If you have multiple build configurations, or even just use the Debug and Release configurations, you can use an If statement in the Post-Build event to decide which batch file to run. So you could create a Debug.bat, Release.bat etc which do what you need. It can be tedious to set them up and get them working correctly at first, but they are very useful once fully implemented.
使用 msbuild 属性自定义您的项目,您可以按照以下步骤进行操作:
转至解决方案资源管理器,右键单击一个项目并选择“卸载项目”来卸载该项目。
然后再次右键单击卸载的项目并选择编辑项目。这将打开项目的 XML 定义,并且您将获得布局的智能感知,这将帮助您执行后续步骤。
在 Visual Studio 编辑器中,找到第一个 PropertyGroup 标记,并在闭合 PropertyGroup 标记附近或末尾添加以下行:
上面的 SolutionDir 在 msbuild 属性中定义,您可以使用以下答案获取该属性: 使用解决方案信息的 msbuild 脚本 并查看众所周知的 msbuild 属性 此处
下一步是找到每个配置的 OutputPath 标记,并像这样编辑它:
上面的示例假设您有一个名为 AutomatedDebug 且目标平台为 x86 的配置。
输出将为
每个项目重复。
要卸载多个项目,请折叠解决方案资源管理器中的所有项目,然后按住 Shift 单击或 Ctrl 单击以选择所有或部分项目,然后右键单击所选组进行卸载,不幸的是,您无法执行此操作以进行编辑,至少在 Visual Studio 中2010。
我是第一个承认这对于现有项目来说有点麻烦的人,但是您可以轻松创建一个 Visual Studio 项目模板,更改这些设置,以便新项目将使用更方便的默认输出目录。
您无法直接在 Visual Studio 中编辑输出目录,因为项目属性编辑器会转义任何 $() 包含的文本。
此外,您只能使用 $() 中包含的系统环境变量的名称来修改 OutputPath。最后一个选项是启用全局输出目录。
如果您直接在命令行中使用 msbuild 构建以这种方式修改的任何单个项目,则输出目录将在您运行 msbuild 的上一级目录中创建。
如果您在团队中,您应该警告他们不要直接手动编辑输出目录,因为此操作将覆盖任何自定义。
希望这些信息有用。
问候。
Customize your project using the msbuild properties which you can do if you follow these steps:
Go to the solution explorer and unload one project by right clicking on it and select Unload Project.
Then right click again on the unloaded project and select Edit Project. This will open the XML definition of your project, and you will have intellisense for the layout which will help you perform the next steps.
In the visual studio editor find the first PropertyGroup tag and add these lines near or at the end of the closing PropertyGroup tag:
The above SolutionDir is defined in msbuild properties which you can obtain using this answer: msbuild script using solution information and also check out the well known msbuild properties here
The next step is to find the OutputPath tag for each configuration and edit it like this:
The example above assumes you have a configuration named AutomatedDebug with destination platform x86.
The output will be
Repeat for each project.
To unload more than one project, collapse all projects in the solution explorer and shift click or ctrl click to select all or some projects, then right click on the selected group to unload, unfortunately you cannot do this for editing, at least in visual studio 2010.
I am the first to admit that this is somewhat cumbersome to do for existing projects, but you could easily create a visual studio project template that has these settings changed so that new projects will use a more convenient default output directory.
You cannot edit the output directory directly in visual studio because the project properties editor escapes any $() enclosed text.
Also you could only modify the OutputPath using the name of a system environment variable enclosed in $(). This last option is to enable a global output directory.
If you build any single project modified in this way using msbuild directly in the commandline the output directory will be created one directory above from where you ran msbuild
If you are in a team, you should warn them not to edit the output directory directly by hand, as this action will overwrite any customization.
Hope this info is useful.
Greetings.