简体   繁体   English

通过VS 2015 RC进行非Azure部署

[英]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私有服务器。 VS 2015 RC发布选项

However, I'm missing out a very important feature: the ability to publish to a non-Azure server. 但是,我错过了一个非常重要的功能:发布到非Azure服务器的能力。 VS 2015 RC发布

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

Preparation 制备

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). 这两个主要目录是: approotwwwroot (如果将应用程序部署到本地文件系统,则可以浏览它们)。 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中创建两个网站/应用程序:

  • one that points to the root application dir and will be used just for deployment. 一个指向根应用程序目录并将仅用于部署。 I will name it mysite-deploy . 我将它命名为mysite-deploy
  • one that will be used to actually host our website and will point to wwwroot dir. 一个将用于实际托管我们的网站,并将指向wwwroot目录。 I will name it simply mysite . 我将其命名为mysite

Deployment 部署

  1. Go to YourprojectDir\\Properties\\PublishProfiles 转到YourprojectDir\\Properties\\PublishProfiles
  2. Create an empty pubxml file (ie 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>
  1. When You press "Publish" in Visual Studio, you should see this new profile on the list. 当您在Visual Studio中按“发布”时,您应该在列表中看到此新配置文件。
  2. Fill out the Connection tab, as you would normally do (set Server, Site Name, etc.). 像往常一样填写“连接”选项卡(设置“服务器”,“站点名称”等)。 Remember to set Site Name to the deployment site ( mysite-deploy ). 请记住将站点名称设置为部署站点( mysite-deploy )。
  3. Validate Connection 验证连接
  4. Try the preview tab - it most probably wouldn't work, but in case it does - you're done. 尝试预览选项卡 - 它很可能不会起作用,但如果确实如此 - 你就完成了。
  5. Click Publish 单击“发布”
  6. Check progress in the Web Publish Activity window. 在“ Web Publish Activity窗口中检查进度。

Possible errors 可能的错误

Out of the box, the publish will probably fail. 开箱即用,发布可能会失败。 Now it gets tricky :) 现在它变得棘手:)

ERROR_FAILED_TO_DESERIALIZE ERROR_FAILED_TO_DESERIALIZE

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. 再试一次。

ERROR_CERTIFICATE_VALIDATION_FAILED ERROR_CERTIFICATE_VALIDATION_FAILED

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'

ERROR_COULD_NOT_CONNECT_TO_REMOTESVC ERROR_COULD_NOT_CONNECT_TO_REMOTESVC

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

ERROR_PROVIDER_NOT_FOUND ERROR_PROVIDER_NOT_FOUND

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

Only the content of wwwroot directory gets deployed 仅部署wwwroot目录的内容

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. 我们希望部署approotwwwroot目录,而不是只有内容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. 在再次发布之前,您可能希望清除服务器上的站点目录 - 现在发布的目录结构将不同。

Testing 测试

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. 在服务器端,您应该看到两个目录: approotwwwroot以及一些脚本文件。

Any server side errors you will have to debug yourself. 您必须自己调试任何服务器端错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM