如何从Visual Studio 2015(+ U1)ASP.NET Core发布到Windows Server 2012R2上的IIS? [英] How can I publish from Visual Studio 2015 (+U1) ASP.NET Core to IIS on Windows Server 2012R2?

查看:80
本文介绍了如何从Visual Studio 2015(+ U1)ASP.NET Core发布到Windows Server 2012R2上的IIS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该问题可以视为两年前的更新,询问如何从Visual Studio 2015中的开放式ASP.NET Core解决方案进行发布(

This question could be considered an update of one from two years ago asking how to publish from an open ASP.NET Core solution in visual studio 2015 (then called ASP.net vnext and briefly also known as ASP.NET 5) to another machine on my local network, which has IIS deployed on it, and which should be used to run the DNX runtime and the ASP.NET application I am writing. Since the wizard provides no help for me, I believe I will have to completely manually configure either an MSDEPLOY solution and its configuration files, or something else equivalent to it.

自从提出最初的问题以来,情况已经发生了很多变化,因此我要求提供ASP.NET 5和DNX 1.0 RC1.

The situation has changed a lot since that original question, so I am asking for ASP.NET 5 and DNX 1.0 RC1.

还有与相关的://stackoverflow.com/questions/27325264/asp-net-5-project-hosting-on-iis>问题,询问如何执行此操作,并提到了WebDeploy 3.6,也指将近2年的历史Beta版本.

There are some related other questions that ask how to do this and mentions WebDeploy 3.6 and is also referring to nearly 2 year old beta releases,.

因此,我相信,既然ASP.NET 5处于候选版本并且功能完善,那么此问题对于Visual Studio 2015应该有一个新的和不同的答案.现在如何完成?

I believe therefore, that this question should have a new and different answer for Visual Studio 2015, now that ASP.NET 5 is at the release candidate and is feature complete. How is it done now?

还应该明确一点,我不是在谈论将我的Visual Studio解决方案从 C:\ DEV \ WORKINGCOPY 部署到我自己计算机的 c:\ inetpub \ wwwroot ,而是通过网络通过web-dav或FTP或SMB共享复制到运行IIS的Windows Server盒中.

Also it should be made clear I'm not talking about deploying from my Visual Studio solution on C:\DEV\WORKINGCOPY to my own machine's c:\inetpub\wwwroot, but rather copying across a network, either via web-dav, or FTP or SMB share, to a windows Server box running IIS.

到目前为止我尝试过的事情:

What I have tried so far:

  • 在文件系统模式下使用内置的发布到Web"向导.结果似乎是可以通过web.cmd运行的东西,它将执行dnx和kestrel,但不会构建可从Windows Server 2012上的IIS 8.x运行的捆绑软件.此外,发布到文件系统模式会创建捆绑软件包括一组名为approot,logs和wwwroot的基本文件夹,我非常确定IIS不应设置为直接提供approot或logs文件夹.如果我从IIS查看wwwroot \文件夹的副本,则会看到500-内部服务器错误.这就是我希望IIS在不知道如何将web.config放入其中并对其执行任何操作时所要做的事情.

  • Use the built in Publish To Web wizard in filesystem mode. The result seems to be something you could run via a web.cmd which will execute dnx and kestrel, but does not build a bundle that is runnable from IIS 8.x on Windows Server 2012. Furthermore, the publish to filesystem mode creates a bunch of stuff including a basic set of folders named approot, logs, and wwwroot, and I am pretty sure that IIS should not be set up to serve up the approot or logs folders directly. If I look at my copy of the wwwroot\ folder from IIS, I see a 500 - Internal server error. That's what I'd expect IIS to do when it has no idea how to take the web.config in there and do anything with it.

试图从命令提示符处手动使用 dnu publish dnu pack ,可能是我可以使用结果替换我的内容XYZ-publish.ps1 powershell文件PublishProfiles.dnu publish命令失败,并显示无法将鲍尔识别为内部或外部命令".dnu pack成功了,但是我不知道如何处理生成的.nupkg文件,以使其在IIS上运行.

Tried to use dnu publish and dnu pack manually from a command prompt, with the idea that perhaps I could use the results to replace the contents of my XYZ-publish.ps1 powershell file PublishProfiles. dnu publish command fails with "bower not recognized as internal or external command". dnu pack succeeds, but I have no idea what to do with the resulting .nupkg files with regards to getting them to run on IIS.

我的总体目标是:

  • 通过单击或键入一个命令即可完成所有操作,包括任何捆绑和构建任何预编译的程序集(nuget程序包是vclass等效于inclassic .net的vNext等效概念).

  • To have everything done in one click or by typing one command, including any bundling and building of any pre-compiled-assemblies (nuget packages being the vNext equivalent concept to Assemblies inclassic .net).

为了向我本人和其他读者表明,在准备好进行部署之前,在IIS上一次完成的任务是什么,每次单击发布时为您完成的任务是什么,以及如何设置它们.

To make clear to myself and other readers what the one time set up tasks on IIS are before you are ready to deploy, and what the tasks are that are done for you each time you click publish, and how to set them up.

这似乎是一个基本领域,此时ASP.NET 5上的文档非常薄弱,并且该工具目前仅针对希望将捆绑软件部署到文件夹并从"dnx网站运行"的人进行了优化.(红est),或者对于那些想要在Azure上进行部署的用户(对于发布"向导中的这种情况,此过程是完全自动化的),而不是那些想要在自己的运行IIS的计算机上进行部署的人.发布向导缺少这种非常明显的情况(对我而言);发布到自己的Windows服务器盒中,并为我创建要使其正常工作所需的任何IIS支架.

This appears to be a fundamental area where the documentation on ASP.NET 5 at this time is extremely weak, and the tooling is currently optimized only for people who want to deploy a bundle to a folder and run it from "dnx web" (kestrel), or for those who want to deploy on Azure (this process is fully automated for those cases within the Publish wizard) not those who want to deploy to their own machine running IIS. The publish wizard is missing this extremely obvious (to me) case; Publish to a Windows server box of my own, and create me any IIS scaffolding that I need to get this working.

推荐答案

更新: Microsoft的Connect 2015演示套件名为Healthcare.biz 的文件包含一个基于Powershell的部署方案(对于Azure),可能适用于本地IIS服务器.请参阅该GitHub存储库中的PublishAspNet5Website.ps1 Powershell脚本.

Update: Microsoft's Connect 2015 demo suite called Healthcare.biz contains a powershell based deployment scenario (for azure) that could probably be adapted to a local IIS server. See the PublishAspNet5Website.ps1 powershell script at that GitHub repo.

这个问题有很多要素,我找不到任何一个能将它们全部识别出来的资料.

There are many elements to this question and I could not find any one source that identified them all.

  1. 首先,根据

  1. First some setup on your IIS Server is required, as per this question, you must select the app pool that will be used to run your DNX/ASP.NET 5 application. You should also create a virtual folder and then convert that into an Application. According to that linked question you should be using a .NET 4 pool. Additional setup on your IIS Server may include setting up server side tooling to accept incoming publish requests from your visual studio (inside IDE) and msbuild command line (continuous integration server) deployment tooling.

由于Visual Studio 2015附带的向导(包括更新1中的向导)没有提供在域上部署到Windows Server"这样的选择,因此您必须研究现有的选项,例如文件模式部署选项和azure部署选项,然后基于这两个起点之一选择某种混合方法.您的资产包括Powershell的所有功能以及dnx/dnu工具的所有功能,包括其Bower集成.您将根据需要捆绑/生成/编译,然后将结果发送到MSDEPLOY工具,然后您需要为其编写配置(.pubxml)文件.您还可以选择完全忽略DEPLOY命令,并选择通过添加到dnx项目中的登台"动词进行部署,以部署到登台服务器.

Because the wizard that comes inside Visual Studio 2015 (including the one in update 1) does not offer a choice like "Deploy to a Windows Server on your domain", you will have to study the existing options, like the file-mode deploy option and the azure deploy option and choose some hybrid approach based on one of those two starting points. Your assets include all the power of powershell, and all the power of the dnx/dnu tooling, including its bower integration. You will bundle/build/compile as needed, and then send the results along to MSDEPLOY tool, which you will then need to write configuration (.pubxml) files for. You also have the option of ignoring the DEPLOY command entirely and choosing to deploy via a "staging" verb you add to your dnx project, to deploy to a staging server.

为了希望将微薄的起始文件设置为执行问题中指定的工作所需的条件,您可能必须阅读MSDEPLOY上的文档.在互联网上搜索时,我发现有一些示例.pubxml文件

In order to have any hope of modifying the meager starting file set into the condition required to do the job specified in the question, you will probably have to read the documentation on MSDEPLOY. Searching around on the internet I have found that there are some example .pubxml files here and there that show how the .pubxml is constructed. Inside your deployment profile folder, you will need at least one properly constructed .pubxml file, and another file with the same base name, and the extension .ps1 (powershell) instead, which appears to be the same no matter which technique you use, so the only reason why it can exist in my view is so you can accomplish other tasks within that powershell.

.pubxml内容示例

Sample .pubxml content

<?xml version="1.0" encoding="utf-8"?>
<!--
 NOTE: I'm pretty sure that the publishprovider should NOT be the one shown here. 
 I do not know what it should be and will update this answer when I figure that fact out.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://ramsoftazurewebappdemo.azurewebsites.net</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <CompileSource>False</CompileSource>
    <_DefaultDNXVersion>dnx-clr-win-x86.1.0.0-rc1-update1</_DefaultDNXVersion>
    <UsePowerShell>True</UsePowerShell>
    <IISCommand>web</IISCommand>
    <WebRoot>wwwroot</WebRoot>
    <WwwRootOut>wwwroot</WwwRootOut>
    <IncludeSymbols>False</IncludeSymbols>
    <Native>False</Native>
    <IgnoreDNXRuntime>False</IgnoreDNXRuntime>
    <MSDeployServiceURL>myservername.mydomain.biz:443</MSDeployServiceURL>
    <DeployIisAppPath>MyWebAppPath</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>$USERNAME</UserName>
    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
  </PropertyGroup>
</Project>

  1. 直接熟悉可用于MSDEPLOY的命令行选项(您可以从该Powershell ps1脚本调用自己)而不是使用.pubxml格式,这可能不会有害.以下是如何调用MSDEPLOY.EXE(在查找文档时也称为Microsoft Web Deploy V3)的示例:

.

  "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" 
  -source:IisApp='C:\dev\PublishOut\YourWebApp\wwwroot
   -dest:IisApp='YourIisAppName',
     ComputerName='https://yourcomputername.yourdomain.biz/msdeploy.axd',
     UserName='$USERNAME',
     Password='secr3t',
     IncludeAcls='False',AuthType='Basic' 
   -verb:sync -enableLink:contentLibExtension  
   -enableRule:DoNotDeleteRule -retryAttempts:3

  1. 如果尚未尝试使用它们,请习惯使用vNext点网实用程序(dnu)命令中的 dnu pack dnu publish 选项.这是如何捆绑ASP.NET源文件以及DNX运行时副本的方式,以便可以在服务器端运行.对我来说,我无法使用dnu publish命令,该命令似乎是客户端资源发布阶段,默认情况下依赖于名为bower的node.js(javascript)工具,我发现我必须手动安装它作为Visual Studio 2015.asp.net 5模板依赖于此工具,但是默认情况下似乎没有安装它(也许我在安装Visual Studio时错过了一个选项,如果是这样,我会更新此答案).
  1. If you haven't tried them yet, get used to the dnu pack and dnu publish options within the vNext dot net utility (dnu) command. This is how you get your ASP.NET source files bundled up, along with a copy of the DNX runtime, so that it's ready to run on the server side. For me, I could not use the dnu publish command which appears to be a client-side resource publishing stage which depends by default on the node.js (javascript) tool called bower, which I found I had to install manually as Visual Studio 2015's asp.net 5 templates depend on this tooling but do not seem to install it by default (maybe I just missed an option when I installed visual studio, I'll update this answer if that's the case).

随着更多细节的融合,我将继续完善和扩展这个答案.我目前正在通过教程仅讨论了在部署到Azure或商业Internet托管问题时如何执行此操作,并且我将尝试使它们适应内部服务器,其中您还负责IIS服务器的配置和任何发布-代理软件,该软件也必须在IIS服务器上配置.

I will continue to refine and expand this answer as more details come together. I am currently following through tutorials that discuss only how to do this when deploying to azure or to commercial internet hosting concerns, and I will attempt to adapt them to in-house servers, where you're also responsible for the configuration of the IIS server and any publish-agent software that must be configured on the IIS server as well.

这篇关于如何从Visual Studio 2015(+ U1)ASP.NET Core发布到Windows Server 2012R2上的IIS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆