Question: How to create a common output directory for multiple projects?
See original GitHub issueHello!
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
If we build the ClassLibrary1, the framework will generate the layout for all referenced libraries.
The output folder after building will be following
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.
Open and compile ClassLibrary2.sln at first.
Output will be copy to Dlls folder
Next, open and compile ClassLibrary1.sln
Look at the Dlls folder again
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:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
Sorry for the wrong mention.
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.