4

I'm trying to publish a the new SDK-style .net core console application project, and facing a problem with publishing a project that uses "Microsoft.NET.Sdk"(please, pay attention, it's not Microsoft.NET.Sdk.Web, which works just fine).

What've I done:

  1. I've added "Microsoft.NET.Sdk.Publish" to a list of project's SDKs:
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">

Here is my whole project.csproj, which is kinda super simple:

<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="CsvHelper">
      <Version>12.1.2</Version>
    </PackageReference>
  </ItemGroup>
</Project>
  1. I use the next command for publishing:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" MySolution.sln -maxCpuCount:1 -nodeReuse:True -target:Build -property:Configuration=Release -property:DeployOnBuild=true -property:PublishProfileFullPath="C:\Profiles\Publish.pubxml" -restore /bl

It creates a folder that I've specified as publishUrl in my publishing profile, but this folder is empty. From what I can see from the binary log, FileSystemPublish target is just skipped, because it has nothing to copy.

The only way to mitigate this problem that I've found is to add:

<_PublishProjectType>AspNetCore</_PublishProjectType>

To my project and then it works well, but this is kinda tricky, cause console application has nothing to do with AspNetCore, and exposes some of the SDK's internals.

Any ideas on how to solve it without relying on SDK's internals?

Smooyk
  • 389
  • 4
  • 20
  • have you tried [dotnet publish](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish) command? – magicandre1981 Jul 13 '20 at 14:06
  • The thing is that we are in the middle of a migration from full framework to .net core and we have mixed core/full framework solutions with multitargeting libraries. Long story short: I can't use dotnet publish at the moment until at least this one is implemented(https://github.com/dotnet/sdk/issues/12196). – Smooyk Jul 13 '20 at 14:23
  • I am missing here the output path, check this out: https://stackoverflow.com/questions/36757316/publish-using-msbuild-outputs-to-unexpected-path – Bruno Jul 13 '20 at 14:51

0 Answers0