Skip to content

Instantly share code, notes, and snippets.

@jstangroome
Created July 11, 2012 04:27
Show Gist options
  • Select an option

  • Save jstangroome/3087991 to your computer and use it in GitHub Desktop.

Select an option

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
<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>
@Flithor
Copy link

Flithor commented Nov 6, 2025

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