views:

1219

answers:

2

Hello,

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

+3  A: 

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.

Jeromy Irvine
your command line would not copy .pdb .config files which may be an issue (not able to debug properly).Using $(OutDir) is quite wrong as well as it refers to the current project and not Core's project.
PowerKiKi
Furthermore this would actually duplicates a lot files. For all plugins depends on Core, it means that the core assembly (and its own dependencies) will be copied in each plugin output folder.
PowerKiKi
The use of $(OutDir) assumes that you have the same target directories setup for both projects build (typically "\bin\Debug"). If that's not the case, you'll have to hard-code it instead.
Jeromy Irvine
Re. second comment: this would not duplicate anything other than the plugin .dlls. It copies them to the Core bin, not the Core binaries to the plugin path.
Jeromy Irvine
When VisualStudio build a plugin it will "import" the Core in the plugin's output folder. What could be done is set "Copy local" to false for all plugins references (including the Core of course). That would work.
PowerKiKi
$(TargetPath) should be $(TargetDir) in the last example, I guess.
mafutrct
+1  A: 

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

Nik Reiman
I tried that. But macros cannot be used in output path. When building it will create directory "$(SolutionDir)".
PowerKiKi
It works if you set it directly in .csproj file.
alexandrul