Can't exclude *.dcproj from dotnet pack

1.1k Views Asked by At

I used Visual Studio 2017 to make a solution with docker-compose support. When I try to pack a nuget package (during a CI process) using dotnet pack MySolution.sln I getting the error MSB4057 saying that it cannot pack the docker-compose.dcproj project. So I tried to use <IsPackable>false</IsPackable> inside my docker-compose.dcproj with no success. So I have to pack my projects one by one or use different solutions for CI and for debugging process - both solutions looks ugly to me.

Does anyone have an idea how to exclude .dcproj file from trying to been packed by dotnet pack?

2

There are 2 best solutions below

0
Andreas Dirnberger On

In the CI script, remove the docker-compose project from the solution before the pack command with

dotnet sln MySol.sln remove docker-compose.dcproj

0
Mikhail Ch On

I had the same problem and I have solved it by adding a dummy "Pack" target to docker-compose.dcproj, so my project looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
  <PropertyGroup Label="Globals">
    <ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
    <ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
    <ProjectVersion>2.1</ProjectVersion>
    <DockerTargetOS>Windows</DockerTargetOS>
    <ProjectGuid>0a1c7d45-3174-4d07-a025-4d5fd55042c0</ProjectGuid>
    <IsPackable>false</IsPackable>
    <IsTestProject>false</IsTestProject>
  </PropertyGroup>
  <PropertyGroup>
    <DockerServiceName>app-name</DockerServiceName>
  </PropertyGroup>
  <ItemGroup>
    <None Include="docker-compose.override.yml">
      <DependentUpon>docker-compose.yml</DependentUpon>
    </None>
    <None Include="docker-compose.yml" />
  </ItemGroup>

  <Target Name="Pack">
  </Target>

</Project>