使用Visual Studio 2008错误地创建输出文件夹

时间:2022-01-22 19:51:03

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.)

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

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").

每个插件OutputPath都是“.. \ Core \ bin \ debug”。当我打开解决方案时,Visual Studio在Solution的文件夹parent中创建一个文件夹“Core \ bin \ debug”,就好像相对路径从.sln文件开始一样。但是,当我构建解决方案时,二进制文件将输出到正确的路径(“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 ?

它对我来说看起来像一个Visual Studio的bug,但也许我忽略了某个选项。任何想法如何解决这个问题?

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

PS:我知道这不是一个关键问题,因为一切都建立并且工作正常,但我不喜欢无意义的文件夹闲置的想​​法

2 个解决方案

#1


3  

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.

您可以为它们创建一个构建后脚本(Properties \ Build Events选项卡),而不是更改插件的输出位置,然后将它们复制到Core文件夹。这样可以防止输出文件夹混淆。

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:

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

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.

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

#2


1  

Instead of using "..\Core\bin\debug", use "$(SolutionDir)\Core\bin\debug".

而不是使用“.. \ Core \ bin \ debug”,请使用“$(SolutionDir)\ Core \ bin \ debug”。

#1


3  

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.

您可以为它们创建一个构建后脚本(Properties \ Build Events选项卡),而不是更改插件的输出位置,然后将它们复制到Core文件夹。这样可以防止输出文件夹混淆。

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:

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

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.

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

#2


1  

Instead of using "..\Core\bin\debug", use "$(SolutionDir)\Core\bin\debug".

而不是使用“.. \ Core \ bin \ debug”,请使用“$(SolutionDir)\ Core \ bin \ debug”。