[英]Non-Azure Deployment through VS 2015 RC
我正在尝试在VS 2015 Enterprise RC上使用ASP.NET 5及其所有新功能。 为了确保顺利的端到端部署,我尝试通过VS Publish功能将应用程序部署到非Azure私有服务器。
但是,我错过了一个非常重要的功能:发布到非Azure服务器的能力。
在早期版本的Visual Studio中(我使用的是VS 2013),自定义选项就在那里。
我尝试过修改项目属性,但没有尝试如何将我的ASP.NET 5应用程序部署到自定义服务器。 有任何想法吗?
它是可行的(毕竟,发布到Azure网站也在内部使用WebDeploy),但它现在有点棘手,需要你调整一些东西。 这是你可以做的(对于VS 2015 CTP6):
Asp.net vnext的目录结构与常规的Asp.net应用程序略有不同。 这两个主要目录是: approot
和wwwroot
(如果将应用程序部署到本地文件系统,则可以浏览它们)。 我们想要部署这两个目录,但IIS网站路径必须指向wwwroot
目录。 这个问题似乎在Web Deploy 3.6中得到解决,但我只是手动处理它。 为此,您可以在IIS中创建两个网站/应用程序:
mysite-deploy
。 wwwroot
目录。 我将其命名为mysite
。 YourprojectDir\\Properties\\PublishProfiles
mysite.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
)。 Web Publish Activity
窗口中检查进度。 开箱即用,发布可能会失败。 现在它变得棘手:)
起初,我得到的是这个错误:
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.
我们试着解决这个问题。
再次打开“ Publish
窗口,然后在“ Settings
选项卡上选中“ Publish using Powershell script
Settings
选项。 再试一次。
如果出现错误: ERROR_CERTIFICATE_VALIDATION_FAILED
,则表示您的计算机不信任目标计算机上的IIS Management Service
的SSL证书。 您可以尝试下载证书,将其添加到受信任的证书存储区,也可以完全禁用证书验证。
在后一种情况下,您需要编辑位于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
。 找到片段:
# add excludes
$sharedArgs.ExtraArgs += (GetInternal-ExcludeFilesArg -publishProperties $publishProperties)
# add replacements
$sharedArgs.ExtraArgs += (GetInternal-ReplacementsMSDeployArgs -publishProperties $publishProperties)
并添加这个:
$sharedArgs.ExtraArgs += '-allowUntrusted'
检查正在调用的确切命令行 - 在Web Publish Activity Window
中应该记录一行,从Calling msdeploy with the command:
开始Calling msdeploy with the command:
。 寻找ComputerName=
。 如果它看起来像这样: 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`。
More Information: The provider 'contentPathLib' could not be found. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_PROVIDER_NOT_FOUND.
再次转到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'
这似乎是Web Deploy 3.6的一个特性,但似乎服务器端也必须支持它。 要禁用它,只需注释掉这一行。 警告:此更改可能会影响到Azure网站的PowerShell部署 。
现在您的站点正在部署,还有一件事。 我们希望部署approot
和wwwroot
目录,而不是只有内容wwwroot
目录部署。 要解决这个问题,我们需要再次编辑C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\Publish\\Scripts\\1.0.0-pre\\publish-module.psm1
。
找到说:
$webrootOutputFolder = (get-item (Join-Path $packOutput $webroot)).FullName
然后,添加一个新行:
$webrootOutputFolder = $webrootOutputFolder | split-path -parent
这会将已发布的文件夹设置为wwwroot
的父级,这正是我们所需要的。 在再次发布之前,您可能希望清除服务器上的站点目录 - 现在发布的目录结构将不同。
此时,应该在服务器上部署并提供该站点。 在服务器端,您应该看到两个目录: approot
和wwwroot
以及一些脚本文件。
您必须自己调试任何服务器端错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.