[英]Non-Azure Deployment through VS 2015 RC
I'm trying out ASP.NET 5 and all its new features on VS 2015 Enterprise RC. 我正在尝试在VS 2015 Enterprise RC上使用ASP.NET 5及其所有新功能。 To ensure smooth end-to-end deployment, I then try to deploy the application to a non-Azure private server through VS Publish feature. 为了确保顺利的端到端部署,我尝试通过VS Publish功能将应用程序部署到非Azure私有服务器。
However, I'm missing out a very important feature: the ability to publish to a non-Azure server. 但是,我错过了一个非常重要的功能:发布到非Azure服务器的能力。
In earlier versions of Visual Studio (I'm using VS 2013), the Custom options is there. 在早期版本的Visual Studio中(我使用的是VS 2013),自定义选项就在那里。
I've tried tinkering with the Project Properties but nothing on how to deploy my ASP.NET 5 app to a custom server. 我尝试过修改项目属性,但没有尝试如何将我的ASP.NET 5应用程序部署到自定义服务器。 Any ideas? 有任何想法吗?
It's doable (after all, publishing to Azure websites also uses WebDeploy internally), but it's kinda tricky right now and requires you to tweak a few things. 它是可行的(毕竟,发布到Azure网站也在内部使用WebDeploy),但它现在有点棘手,需要你调整一些东西。 Here's what you can do (for VS 2015 CTP6): 这是你可以做的(对于VS 2015 CTP6):
Asp.net vnext has slightly different directory structure than a regular Asp.net app. Asp.net vnext的目录结构与常规的Asp.net应用程序略有不同。 The are two main directories: approot
and wwwroot
(if you deploy the application to local filesystem, you can browse through them). 这两个主要目录是: approot
和wwwroot
(如果将应用程序部署到本地文件系统,则可以浏览它们)。 We want to deploy both those dirs, but the IIS website path has to point to wwwroot
dir. 我们想要部署这两个目录,但IIS网站路径必须指向wwwroot
目录。 This problem seems to be addressed in Web Deploy 3.6 , but i will just deal with it manually. 这个问题似乎在Web Deploy 3.6中得到解决,但我只是手动处理它。 In order for this to work, you can create two websites/applications in IIS: 为此,您可以在IIS中创建两个网站/应用程序:
mysite-deploy
. 我将它命名为mysite-deploy
。 wwwroot
dir. 一个将用于实际托管我们的网站,并将指向wwwroot
目录。 I will name it simply mysite
. 我将其命名为mysite
。 YourprojectDir\\Properties\\PublishProfiles
转到YourprojectDir\\Properties\\PublishProfiles
mysite.pubxml
) 创建一个空的pubxml文件(即mysite.pubxml
) Paste the following content into your pubxml: 将以下内容粘贴到pubxml中:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
</PropertyGroup>
</Project>
mysite-deploy
). 请记住将站点名称设置为部署站点( mysite-deploy
)。 Web Publish Activity
window. 在“ Web Publish Activity
窗口中检查进度。 Out of the box, the publish will probably fail. 开箱即用,发布可能会失败。 Now it gets tricky :) 现在它变得棘手:)
At first, what I've got is this error: 起初,我得到的是这个错误:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.AspNet.Publishing.targets(205,5): Error ERROR_FAILED_TO_DESERIALIZE: Web deployment task failed. ()
Publish failed to deploy.
Let's try to fix that. 我们试着解决这个问题。
Open the Publish
window again, and check Publish using Powershell script
option on the Settings
tab. 再次打开“ Publish
窗口,然后在“ Settings
选项卡上选中“ Publish using Powershell script
Settings
选项。 Try again. 再试一次。
If you get an error: ERROR_CERTIFICATE_VALIDATION_FAILED
, this means that the SSL certificate that IIS Management Service
on your target machine is not trusted by your computer. 如果出现错误: ERROR_CERTIFICATE_VALIDATION_FAILED
,则表示您的计算机不信任目标计算机上的IIS Management Service
的SSL证书。 You can try to download the certificate add it to trusted cert store, or you can disable certificate validation altogether. 您可以尝试下载证书,将其添加到受信任的证书存储区,也可以完全禁用证书验证。
In the latter case, you need to edit publish-module.psm1
located at C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
. 在后一种情况下,您需要编辑位于C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
publish-module.psm1
C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
。 Find the fragment: 找到片段:
# add excludes
$sharedArgs.ExtraArgs += (GetInternal-ExcludeFilesArg -publishProperties $publishProperties)
# add replacements
$sharedArgs.ExtraArgs += (GetInternal-ReplacementsMSDeployArgs -publishProperties $publishProperties)
And add this: 并添加这个:
$sharedArgs.ExtraArgs += '-allowUntrusted'
Inspect the exact commandline that is getting invoked - in Web Publish Activity Window
there should be a line logged, starting with Calling msdeploy with the command:
. 检查正在调用的确切命令行 - 在Web Publish Activity Window
中应该记录一行,从Calling msdeploy with the command:
开始Calling msdeploy with the command:
。 Look for ComputerName=
. 寻找ComputerName=
。 If it looks like this: ComputerName='https://https://myhost:8172/msdeploy.axd'
/msdeploy.axd' , then you should change
Server field in Publish profile
Connection tab to:
myhost:8172 . That's because the powershell script automatically adds
如果它看起来像这样: ComputerName='https://https://myhost:8172/msdeploy.axd'
msdeploy.axd' , then you should change
field in Publish profile
连接tab to:
服务器field in Publish profile
, then you should change
tab to:
myhost:8172 . That's because the powershell script automatically adds
. That's because the powershell script automatically adds
https:// and
/msdeploy.axd`. . That's because the powershell script automatically adds
https:// and
/ msdeploy.axd`。
More Information: The provider 'contentPathLib' could not be found. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_PROVIDER_NOT_FOUND.
Go again to C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
and find the line: 再次转到C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
并找到以下行:
$publishArgs += '-enableLink:contentLibExtension'
This seems to be a feature of Web Deploy 3.6 , but it seems that the server side has to support it also. 这似乎是Web Deploy 3.6的一个特性,但似乎服务器端也必须支持它。 To disable it, just comment out this line. 要禁用它,只需注释掉这一行。 Warning: This change may impact powershell deployment to Azure websites . 警告:此更改可能会影响到Azure网站的PowerShell部署 。
Now that your site is being deployed, there is one more thing. 现在您的站点正在部署,还有一件事。 We wanted to deploy approot
and wwwroot
directory, and instead only the content of the wwwroot
directory is deployed. 我们希望部署approot
和wwwroot
目录,而不是只有内容wwwroot
目录部署。 To fix that, we need to once again edit C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
. 要解决这个问题,我们需要再次编辑C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
。
Find the line that says: 找到说:
$webrootOutputFolder = (get-item (Join-Path $packOutput $webroot)).FullName
And after that, add a new line: 然后,添加一个新行:
$webrootOutputFolder = $webrootOutputFolder | split-path -parent
This will set the published folder to the parent of wwwroot
, which is exactly what we need. 这会将已发布的文件夹设置为wwwroot
的父级,这正是我们所需要的。 Before publishing again, you may want to clear your site's directory on the server - the published directory structure will be different now. 在再次发布之前,您可能希望清除服务器上的站点目录 - 现在发布的目录结构将不同。
At this point, the site should be deployed and available on the server. 此时,应该在服务器上部署并提供该站点。 On the server side, you should see two directories: approot
and wwwroot
and maybe some script files. 在服务器端,您应该看到两个目录: approot
和wwwroot
以及一些脚本文件。
Any server side errors you will have to debug yourself. 您必须自己调试任何服务器端错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.