非Azure的部署,通过2015年VS RC [英] Non-Azure Deployment through VS 2015 RC

查看:393
本文介绍了非Azure的部署,通过2015年VS RC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了ASP.NET 5和VS 2015年企业RC它所有的新功能。为了确保顺利终端到终端的部署,我再尝试通过部署VS应用到非Azure的专用服务器发布功能。

不过,我错过了一个非常重要的功能:发布到非Azure的服务器的能力。

在Visual Studio早期版本(我使用VS 2013年)的,自定义选项是存在的。

我试过的项目属性,但没有就如何我的ASP.NET应用程序5部署到自定义服务器修修补补。有任何想法吗?


解决方案

这是可行的(毕竟,发布到Azure的网站也使用WebDeploy内部),但它现在还挺棘手,需要你调整一些东西。
这里是你可以做什么(为2015年VS CTP6):

preparation

Asp.net vnext比常规Asp.net应用程序略有不同的目录结构。在两个主要的目录:为approot 的wwwroot (如果应用程序部署到本地文件系统,你可以通过他们浏览)。我们希望部署这两个迪尔斯,但IIS网站的路径必须指向的wwwroot DIR。这个问题似乎在 Web部署3.6 ,但我只是将手工处理。为了这个工作,你可以创建两个网站/ IIS中的应用:

部署


  1. YourprojectDir \\属性\\ PublishProfiles

  2. 创建一个空文件pubxml(即 mysite.pubxml

以下内容粘贴到您的pubxml:

 <?XML版本=1.0编码=UTF-8&GT?;
<项目ToolsVersion =4.0的xmlns =htt​​p://schemas.microsoft.com/developer/msbuild/2003>
  <&的PropertyGroup GT;
    < WebPublishMethod> MSDeploy< / WebPublishMethod>
    < MSDeployPublishMethod>&WMSVC LT; / MSDeployPublishMethod>
  < /&的PropertyGroup GT;
< /项目>

<醇开始=3>

  • 当您preSS发布在Visual Studio中,你应该可以看到这个新的配置文件就行了。

  • 填写连接选项卡,因为你通常会做(组服务器,网站名称等)。记得设置站点名称到部署网站( mysite的部署)。

  • 验证连接

  • 尝试在preVIEW标签 - 它最有可能是行不通的,但如果它 - 大功告成

  • 单击发布

  • 检查在网​​页进度发布活动窗口。

  • 可能的错误

    开箱,发布可能会失败。现在,它变得非常棘手:)

    ERROR_FAILED_TO_DESERIALIZE

    起初,我所得到的是这个错误:

      C:\\ Program Files文件(x86)的\\的MSBuild \\微软\\ VisualStudio的\\ v14.0 \\网络\\ Microsoft.AspNet.Publishing.targets(205,5):错误ERROR_FAILED_TO_DESERIALIZE:网络部署任务失败。 ()
    发布未能部署。

    让我们尝试解决这个问题。

    再次打开发布窗口,检查发布使用于PowerShell脚本选项设置设置页。
    再试一次。

    ERROR_CERTIFICATE_VALIDATION_FAILED

    如果你得到一个错误: ERROR_CERTIFICATE_VALIDATION_FAILED ,这意味着SSL证书 IIS管理服务你的目标机器是不是由您的计算机信任。您可以尝试下载证书添加到受信任的证书存储,或者你可以完全禁用证书验证。

    在后一种情况下,你需要编辑发布 - module.psm1 位于 C:\\ Program Files文件(x86)的\\微软的Visual Studio 14.0 \\ Common7 \\ IDE \\扩展\\微软\\ WEB TOOLS \\发布\\脚本\\ 1.0.0- pre \\发布 - module.psm1 。查找片段:

     #添加排除
            $ sharedArgs.ExtraArgs + =(GetInternal-ExcludeFilesArg -publishProperties $ publishProperties)
            #添加替换
            $ sharedArgs.ExtraArgs + =(GetInternal-ReplacementsMSDeployArgs -publishProperties $ publishProperties)

    和补充一点:

      $ sharedArgs.ExtraArgs + ='-allowUntrusted

    ERROR_COULD_NOT_CONNECT_TO_REMOTESVC

    检查,这是获得援引确切的命令行 - 在网​​络发布活动窗口应该有一个行记录,用开始调用msdeploy用命令。查找计算机名= 。如果它看起来像这样:计算机名='https://开头的https://为m​​yhost:8172 / msdeploy.axd /msdeploy.axd,那么你应该更改服务器字段中发布的个人资料连接标签:为myhost:8172 。这是因为PowerShell脚本会自动添加的https:// / msdeploy.axd`。

    ERROR_PROVIDER_NOT_FOUND

     更多信息:提供程序contentPathLib'不能被发现。了解更多:http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_PROVIDER_NOT_FOUND。

    再转到 C:\\ Program Files文件(x86)的\\微软的Visual Studio 14.0 \\ Common7 \\ IDE \\扩展\\微软\\网络工具\\发布\\脚本\\ 1.0.0- pre \\发布 - module.psm1 并找到行:

      $ publishArgs + ='-enableLink:contentLibExtension

    这似乎是网络的功能部署3.6 ,但似乎在服务器端有支持它也。要禁用它,只是注释掉这一行。 警告:这种变化可能会影响PowerShell的部署Azure的网站

    只有wwwroot目录内容被部署

    现在您的网站正在部署,还有一件事。我们希望部署为approot 的wwwroot 目录中,而不是只有 wwwroot文件<内容/ code>目录部署。为了解决这个问题,我们需要再次修改 C:\\ Program Files文件(x86)的\\微软的Visual Studio 14.0 \\ Common7 \\ IDE \\扩展\\微软\\网络工具\\发布\\脚本\\ 1.0.0- pre \\发布 - module.psm1

    查找这行:

      $ webrootOutputFolder =(获得项目(联接路径$ packOutput $ Webroot公司))。全名

    在这之后,添加一个新行:

      $ webrootOutputFolder = $ webrootOutputFolder |分离路径-parent

    这将发布的文件夹设置为的wwwroot 的母公司,而这正是我们需要的。再次发布之前,您可能希望清除服务器上的站点的目录 - 现在公布的目录结构会有所不同。

    测试

    此时,在网站上应该部署和在服务器上可用。在服务器端,你应该看到两个目录:为approot 的wwwroot ,也许一些脚本文件

    任何服务器端错误,你将不得不调试自己。

    I'm trying out ASP.NET 5 and all its new features on VS 2015 Enterprise RC. To ensure smooth end-to-end deployment, I then try to deploy the application to a non-Azure private server through VS Publish feature.

    However, I'm missing out a very important feature: the ability to publish to a non-Azure server.

    In earlier versions of Visual Studio (I'm using VS 2013), the Custom options is there.

    I've tried tinkering with the Project Properties but nothing on how to deploy my ASP.NET 5 app to a custom server. 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. Here's what you can do (for VS 2015 CTP6):

    Preparation

    Asp.net vnext has slightly different directory structure than a regular Asp.net app. The are two main directories: approot and wwwroot (if you deploy the application to local filesystem, you can browse through them). We want to deploy both those dirs, but the IIS website path has to point to wwwroot dir. This problem seems to be addressed in Web Deploy 3.6, but i will just deal with it manually. In order for this to work, you can create two websites/applications in IIS:

    • one that points to the root application dir and will be used just for deployment. I will name it mysite-deploy.
    • one that will be used to actually host our website and will point to wwwroot dir. I will name it simply mysite.

    Deployment

    1. Go to YourprojectDir\Properties\PublishProfiles
    2. Create an empty pubxml file (i.e. mysite.pubxml)

    Paste the following content into your 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.
    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).
    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.

    Possible errors

    Out of the box, the publish will probably fail. Now it gets tricky :)

    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. Try again.

    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. 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. 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

    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:. Look for ComputerName=. If it looks like this: ComputerName='https://https://myhost:8172/msdeploy.axd'/msdeploy.axd', then you should changeServerfield in Publish profileConnectiontab to:myhost:8172. That's because the powershell script automatically addshttps://and/msdeploy.axd`.

    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:

    $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. To disable it, just comment out this line. Warning: This change may impact powershell deployment to Azure websites.

    Only the content of wwwroot directory gets deployed

    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. 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.

    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. 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.

    Any server side errors you will have to debug yourself.

    这篇关于非Azure的部署,通过2015年VS RC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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