Visual Studio 2017 ASP.Net Publish Self-Contained

2019-07-08 23:55发布

I have a .Net Core ASP.Net application in Visual Studio 2017. I am trying to do a self contained deployment of the application.

If I run the following command from the CLI it works exactly how I want and produces a .exe

dotnet publish -c release -r win7-x64

However if I publish from Visual Studio 2017 it does not produce a .exe and produces a .dll instead.

How can I replicate the -r win7-x64 of the dotnet publish command from within Visual Studio 2017?

Here is the contents of my .pubxml

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <PublishFramework>netcoreapp1.1</PublishFramework>
    <ProjectGuid>74bc47dd-6787-420d-804f-3f3d689d5ae5</ProjectGuid>
    <publishUrl>C:\Deploy\JLM.MS.LeadGen.Dealer</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
  </PropertyGroup>
</Project>

2条回答
神经病院院长
2楼-- · 2019-07-09 00:32

This experience has been added to the publish window for Visual Studio 2017 version 15.3 (which can be downloaded here)

If you right click on your project -> Publish -> click the "Settings..." link under "Summary" -> go to the Settings tab of the Publish window, you should see a Target Runtime dropdown where you can choose which platform you want your app to run on. Here's a screenshot of what I'm talking about.

Make sure in your project file to include the runtime you want to select in <RuntimeIdentifiers> or <RuntimeIdentifier>, as the dropdown looks for these properties in order to populate its values.

查看更多
做个烂人
3楼-- · 2019-07-09 00:41

You need to add

<OutputType>Exe</OutputType>

to your .csproj

查看更多
登录 后发表回答