question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: How to create a common output directory for multiple projects?

See original GitHub issue

Hello!

We want to organize a project`s hierarchy in such way

  • [Dlls] - All libraries output placement here. All libraries use this folder for assembly references.
  • [ClassLibrary1]
    • ClassLibrary1.sln
    • ClassLibrary1.csproj
  • [ClassLibrary2]
    • ClassLibrary2.sln
    • ClassLibrary2.csproj …

The key feature - all ClassLibraries have the same output path <OutputPath>…\Dlls</OutputPath>

I notice sometimes such approach causes compilation errors like this

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4651,5): error MSB3030: Could not copy the file “C:\source\repos\UwpApp1\Dlls\ClassLibrary2\ClassLibrary2.xr.xml” because it was not found. 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4651,5): error MSB3030: Could not copy the file “C:\source\repos\UwpApp1\Dlls\ClassLibrary2\Themes\generic.xbf” because it was not found.

After some research I found why this happened.

For example, we have a ClassLibrary2 referenced in ClassLibrary1

image

If we build the ClassLibrary1, the framework will generate the layout for all referenced libraries.

The output folder after building will be following

image

Now, take into account that we have the same output directory for all class libraries. This means that ClassLibrary1 will use the ClassLibrary2 assembly from Dlls directory and also will regenerate layout for it at same time. This is the reason of compilation errors. Before build the output directories are cleared. Due to the ClassLibrary2 is the reference of ClassLibrary1, the folder ‘ClassLibrary2’ is cleared too (all xbf files are deleted).

To demonstrate it practically I have attached a sample.

OutputHierarchy.zip

Open and compile ClassLibrary2.sln at first.

Output will be copy to Dlls folder

image

Next, open and compile ClassLibrary1.sln

Look at the Dlls folder again

image

And the last step - rebuild the ClassLibrary1.sln. Now you have got the errors as I wrote above

error MSB3030: Could not copy the file “C:\Sandbox\OutputHierarchy\Dlls\net5.0\ClassLibrary2\Themes\generic.xbf” because it was not found.

Look at the Dlls\ClassLibrary2\Themes folder and note that generic.xbf was deleted.

So the question is what is the best way to avoid this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
BorzillaRcommented, Oct 3, 2020

@weitzhandler

The “sharing an output directory”

@weltkante I guess that makes us twins…

Sorry for the wrong mention.

0reactions
github-actions[bot]commented, Jul 28, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio: Set same output directory for multiple exe ...
When I set output directory of all exe projets to folder W:\Cci, I got errors from a file named W:\Cci\Debug\net6.0.NETCoreApp,Version=v6.0.
Read more >
Set multiple executable projects to a common output path ...
I am looking for a way to combine all my “Applications” references into a common directory inside the AppX package. The project types...
Read more >
How to: Organize Project Output Files for Builds
The location of project output settings can be found in the project's Property Pages. Expand the node next to Configuration Properties and ...
Read more >
Is it possible to set a default "Output Directory" for all NEW ...
I know how to manually change the "Output Directory" field under "Project Properties -> Configuration Properties -> General.
Read more >
[Solved]-How to build all projects in one single folder?-C#
Right click on each project, select Properties from context menu, then select Build tab. Ont the bottom in Output section change Output path:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found