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:
- 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>
- 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?