2016-12-20 190 views
4

最近,我已经安装了带有.NET Core Preview 4 SDK的VS 2017 RC。 在新的SDK,没有project.json,只有csproj文件:发布自包含的应用.NET核心应用程序

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

的问题是,现在,dotnet publish输出dll,不exe文件。 我试图运行dotnet publish -r win10-x64但它甚至没有编译。

如何在dotnet 1.1 Preview中制作自包含的应用程序? 也许我应该在csproj中指定runtime部分(就像它在json中需要)?

回答

4

我相信,你应该做到以下几点:

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

你需要初步建成了。

另一件事情表明,.csproj和project.json函数几乎相同。因此,应该配置.csproj:

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

以上是指定核心/自包含功能的正确方法。你可以找到很多关于它的信息here

+0

构建失败(指定了win10-x64标志,没有 - 没关系) - 没有识别nuget包。 – pwas

+0

管理编译,但没有运气: 'Microsoft(R)Build Engine版本15.1.458.808 版权所有(C)Microsoft Corporation。版权所有。 SquadPlanning - > C:\ Users \ patry \ Documents \ Visual Studio 2017 \ Projects \ SquadPlanning \ src \ SquadPlanning \ bin \ Debug \ netcoreapp1.0 \ SquadPlanning.dll'仍然是dll。 – pwas

+0

使用的命令:'dotnet build -r win10-x64'和'dotnet publish -r win10-x64'。 – pwas

相关问题