I've created three .NET Standard class librariy C# projects with Visual Studio 2017 and default settings.
Projects:
- MainProject
- TimeProject
- Dependencies -> MainProject
- ClockProject
- Dependencies -> TimeProject
Each of them must have its own output directory like:
<OutputPath>C:\Projects\DataControl\Build\MainProject</OutputPath>
<OutputPath>C:\Projects\DataControl\Build\TimeProject</OutputPath>
<OutputPath>C:\Projects\DataControl\Build\ClockProject</OutputPath>
The project DLL files are placed the output directories but the problem is that the referenced project DLLs are also placed in the output directory (TimeProject.dll and MainProject.dll)
Output directories (Copy Local = true):
- \Build\MainProject:
- MainProject.dll
- \Build\TimeProject
- MainProject.dll
- TimeProject.dll
- \Build\ClockProject
- MainProject.dll
- TimeProject.dll
- ClockProject.dll
If I changed the property Copy Local
to false, the DLL from the directly referenced project disappears. Thats better, but the nested referenced DLL remains -> MainProject.dll in ClockProject.
Output directories (Copy Local = false):
- \Build\MainProject:
- MainProject.dll
- \Build\TimeProject
- TimeProject.dll
- \Build\ClockProject
- MainProject.dll
- ClockProject.dll
I want to prevent that the ClockProject creates a MainProject.dll in its output directory because the MainProject.dll already exists in the output directory of the MainProject.
I've a huge project and under this circumstance I have a lot of the same DLLs in my project folders. During the start of my program, however, a logic also searches the subfolders for DLLs and then several DLLs of the same project are found, this leads to version conflicts. In general, I want to keep this logic, so I am looking for a solution that will only generate the project DLL, not the referenced ones.
Finally, my csproj file. The other two project files look similar.
ClockProject.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>C:\Projects\DataControl\Build\ClockProject</OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TimeProject\TimeProject.csproj">
<Private>false</Private>
</ProjectReference>
</ItemGroup>
</Project>
ClockProject
. When on a build server, it is fairly trivial to exclude unwanted DLLs when they are copied as artifacts. What is the scenario you are trying to solve for? – Wen