Publishing a standalone .NET Core application

I recently installed VS 2017 RC with the .NET Core Preview 4 SDK. There is no file in the new SDK project.json, only csproj:

<PropertyGroup>
   <OutputType>winexe</OutputType>
   <TargetFramework>netcoreapp1.0</TargetFramework>
     <PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup

The problem is what the dotnet publishoutput is now dll, not the exefile. I tried to run dotnet publish -r win10-x64, but it doesn't even compile.

How can I make a standalone application in dotnet 1.1 Preview? Maybe I should specify the section runtimein csproj (as it was in json)?

+4
source share
1 answer

I suppose you should do the following:

dotnet build -r win10-x64
dotnet publish -c release -r win10-x64

You need to create it first.

Another designation: the .csproj and project.json functions are almost identical. Therefore, you must configure the .csproj configuration:

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
    <VersionPrefix>1.0.0</VersionPrefix>
    <DebugType>Portable</DebugType>
    <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App">
      <Version>1.0.1</Version>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json">
      <Version>9.0.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161102-2</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
  </ItemGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

- / , . .

+4

Source: https://habr.com/ru/post/1664341/


All Articles