I have a project Project.Api
that references another project Project.DomainModel
. When I build the API project for release by running
dotnet restore && dotnet build -c Release
It builds successfully. However, when I try to publish
dotnet publish -c Release -o published --no-restore --no-build ./Project.Api
I get this error:
/usr/local/share/dotnet/sdk/2.1.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(168,5): error MSB3030: Could not copy the file "xxxx/Project.DomainModels/bin/Debug/netcoreapp2.1/Project.DomainModels.dll" because it was not found. [xxxx/Project.Api/Project.Api.csproj]
According to the error, it's looking for the referenced project in the Debug
directory, but of course it won't find it there because it will be in the Release
directory.
Project.Api.csproj
file looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project.DomainModels\Project.DomainModels.csproj" />
</ItemGroup>
</Project>
Any idea why it is looking in the Debug directory instead of Release? Getting this on both a Mac and linux machine.