Created
July 11, 2012 04:27
-
-
Save jstangroome/3087991 to your computer and use it in GitHub Desktop.
MSBuild snippet to disable the default DLL output of a C# class library project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project> | |
| <!-- the usual stuff --> | |
| <!-- BEGIN disable default compile and copy binary behaviour --> | |
| <Target Name="CoreCompile" /> | |
| <PropertyGroup> | |
| <SkipCopyBuildProduct>true</SkipCopyBuildProduct> | |
| </PropertyGroup> | |
| <!-- END disable default compile and copy binary behaviour --> | |
| </Project> |
<GenerateDependencyFile>False%lt;/GenerateDependencyFile> does nothing.
Note you may also want to turn of debug symbols to also stop generation of a .pdb file.
EDIT: and if you're doing that, use the following code, both need these values:
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>Full .csproj example as non dll complie project:
<Project Sdk="Microsoft.Build.NoTargets/3">
<PropertyGroup>
<!-- Required, for your target platform -->
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<!-- Belows you want to do anything, here is work for publish multiple project -->
<Target Name="PublishAll" AfterTargets="publish" >
<MSBuild Projects="Other_Project_Path_You_Want_1.csproj"
Targets="Publish"
Properties="PublishDir=$(MSBuildProjectDirectory)\$(PublishDir)ProjectOutput1\" />
<MSBuild Projects="Other_Project_Path_You_Want_2.csproj"
Targets="Publish"
Properties="PublishDir=$(MSBuildProjectDirectory)\$(PublishDir)ProjectOutput2\" />
</Target>
</Project>Alternative solution if the above not work:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Required, for your target platform -->
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- no .deps.json file -->
<GenerateDependencyFile>false</GenerateDependencyFile>
<!-- no .pdb file -->
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
</PropertyGroup>
<!-- import build target before to override Publish and Build targets in default -->
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<!-- override build or publish, won't generate dll file -->
<Target Name="Publish" />
<Target Name="Build" />
<!-- Belows you want to do anything, here is work for publish multiple project -->
<Target Name="PublishAll" AfterTargets="publish" >
<MSBuild Projects="Other_Project_You_Want_1.csproj"
Targets="Publish"
Properties="PublishDir=$(MSBuildProjectDirectory)\$(PublishDir)ProjectOutput1\" />
<MSBuild Projects="Other_Project_You_Want_2.csproj"
Targets="Publish"
Properties="PublishDir=$(MSBuildProjectDirectory)\$(PublishDir)ProjectOutput2\" />
</Target>
</Project>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a Core project you might want to add the following to prevent the .deps.json file from being created:
<GenerateDependencyFile>False</GenerateDependencyFile>