Skip to main content
4 of 4
Active reading [<https://en.wikipedia.org/wiki/.NET_Core>].
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

The following will produce, in the output directory,

  • all the package references
  • the output assembly
  • the bootstrapping exe

But it does not contain all .NET Core runtime assemblies.

<PropertyGroup> <Temp>$(SolutionDir)\packaging\</Temp> </PropertyGroup> <ItemGroup> <BootStrapFiles Include="$(Temp)hostpolicy.dll;$(Temp)$(ProjectName).exe;$(Temp)hostfxr.dll;"/> </ItemGroup> <Target Name="GenerateNetcoreExe" AfterTargets="Build" Condition="'$(IsNestedBuild)' != 'true'"> <RemoveDir Directories="$(Temp)" /> <Exec ConsoleToMSBuild="true" Command="dotnet build $(ProjectPath) -r win-x64 /p:CopyLocalLockFileAssemblies=false;IsNestedBuild=true --output $(Temp)" > <Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" /> </Exec> <Copy SourceFiles="@(BootStrapFiles)" DestinationFolder="$(OutputPath)" /> </Target> 

I wrapped it up in a sample here: https://github.com/SimonCropp/NetCoreConsole

Simon
  • 35.1k
  • 22
  • 142
  • 211