本文介绍了使用 Visual Studio 2008 错误创建的输出文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多项目的解决方案.实际上有一个核心项目和一些插件.我更改了所有插件的 OutputPath,因此所有二进制文件最终都位于 Core bin\debug 文件夹中.(这是必要的,因为 Core 没有关于插件的引用,因此它在编译时不会包含"插件二进制文件.)

所以基本上我的文件夹结构如下:

解决方案我的解决方案.sln插件1\插件2\核心\bin\调试

每个插件的输出路径都是..\Core\bin\debug".当我打开解决方案时,Visual Studio 在解决方案的父文件夹中创建一个文件夹Core\bin\debug",就好像相对路径从 .sln 文件开始一样.但是,当我构建解决方案时,二进制文件会输出到正确的路径(Solution\Core\bin\debug").

核心\bin\调试

对我来说这看起来像是 Visual Studio 的错误,但也许我在某处忽略了某些选项.任何想法如何解决这个问题?

PS:我知道这不是一个关键问题,因为一切都可以构建并且运行良好,但是我不喜欢无意义的文件夹闲置的想​​法

解决方案

与其更改插件的输出位置,您可以做的是为它们创建一个构建后脚本(Properties \ Build Events 选项卡)将它们复制到核心文件夹.这将防止与输出文件夹混淆.

这个命令行应该可以帮到你:

copy "$(TargetPath)" "$(SolutionDir)Core\$(OutDir)"

如果您还需要复制 .pdb 和 .config 文件,您可以添加更多行:

copy "$(TargetPath).pdb" "$(SolutionDir)Core\$(OutDir)"复制 "$(TargetPath).config" "$(SolutionDir)Core\$(OutDir)"

如果你真的想用一行来完成,这也应该可行,虽然它不那么干净:

copy "$(TargetPath)*" "$(SolutionDir)Core\$(OutDir)"

如果您在主项目和附加组件中没有使用相同的输出路径,则需要将 $(OutDir) 替换为硬编码值.如果您将它们设置为针对典型的\bin\Debug"文件夹(或刚刚保留默认值),那么您可以使用 $(OutDir) 值.

I have a solution with many projects. There is actually a Core project and a few plugins. I changed OutputPath for all plugins so all binaries end up in the Core bin\debug folder. (this is necessary as the Core do not have a reference on plugins, hence it does not "include" plugins binaries when it is compiled.)

So basically my folder structure is as follow:

Solution
  MySolution.sln
  Plugin1\
  Plugin2\
  Core\bin\debug

Each plugin OutputPath is "..\Core\bin\debug". When I open the solution Visual Studio creates a folder "Core\bin\debug" in Solution's folder parent as if the relative path starts from .sln file. However when I build the solution the binaries are output to the correct path ("Solution\Core\bin\debug").

Core\bin\debug

It looks like a Visual Studio bug to me, but maybe I overlooked some option somewhere. Any ideas how to resolve this problem ?

PS: I know this not a critical issue as everything build and works fine, however I dislike the idea of meaningless folder hanging around

解决方案

Rather than changing the output location of the plug-ins, what you could do is create a post-build script (Properties \ Build Events tab) for them that will copy the them to the Core folder. That would prevent the confusion with output folders.

This command line should do the trick for you:

copy "$(TargetPath)" "$(SolutionDir)Core\$(OutDir)"

If you need to copy .pdb and .config files as well, you can add more lines:

copy "$(TargetPath).pdb" "$(SolutionDir)Core\$(OutDir)"
copy "$(TargetPath).config" "$(SolutionDir)Core\$(OutDir)"

If you really want to do it with a single line, this should also work, though it's not as clean:

copy "$(TargetPath)*" "$(SolutionDir)Core\$(OutDir)"

If you're not using the same output path in both the main project and the add-ons, you'll need to replace $(OutDir) with a hard-coded value. If you have them set to target the typical "\bin\Debug" folder (or have just left the defaults in place), then you can get away with using the $(OutDir) value.

这篇关于使用 Visual Studio 2008 错误创建的输出文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:40