不能部署precompiled,合并的web应用天青 [英] Can't deploy precompiled, merged webapp to Azure

查看:735
本文介绍了不能部署precompiled,合并的web应用天青的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图部署ASP.NET Web应用程序的Azure。这是混合Web窗体,MVC和的WebAPI,还有的ASPX / ASCX文件一吨,这样,他们真正需要的是precompiled或每部署将使该网站低迷一段时间。

I'm trying to deploy an ASP.NET web application to Azure. It's hybrid Web Forms, MVC, and WebAPI, and there are a TON of aspx/ascx files, such that they really need to be precompiled or every deploy will render the site sluggish for awhile.

我试图通过SCM集成GitHub上通过捻部署,以precompiled观点,所有合并为一个单一的组件。

I am trying to deploy via SCM integration with GitHub via kudu, with precompiled views, all merged to a single assembly.

需要注意的是:


  • 部署工作正常禁用precompilation。

  • 部署工作从Visual Studio
  • 罚款
  • 构建工作正常,如果我从Azure的日志复制的MSBuild命令,更换相关的路径,并在本地我的Windows 8.1的机器上运行它。

我已经设置了高级precompile设置:

I've set up the Advanced Precompile settings as:


  • 请不要让precompiled网站是udpatable

  • 请不要发出调试信息

  • 合并所有页面和控制输出到单个总成= AppViews.dll

下面是在 .deployment 文件的Azure

Here's the .deployment file for Azure

[config]
project = WebSite/WebSite.csproj
SCM_BUILD_ARGS=/p:Configuration=Release;PublishProfile=azure-prod /v:n

您看到我送的冗长 / V 正常额外的诊断信息。

You notice I'm sending the verbosity /v to "normal" for extra diagnostic information.

下面的信息,我向部署日志的尾部​​得到:

Here is info I get toward the tail of the deployment log:

AspNetPreCompile:
  D:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v \ -p D:\home\site\repository\WebSite\obj\Release\AspnetCompileMerge\Source -c D:\home\site\repository\WebSite\obj\Release\AspnetCompileMerge\TempBuildDir 
GenerateAssemblyInfoFromExistingAssembleInfo:
  Creating directory "obj\Release\AssemblyInfo".
  D:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /out:obj\Release\AssemblyInfo\AssemblyInfo.dll /target:library Properties\AssemblyInfo.cs
AspNetMerge:
  Running aspnet_merge.exe.
  D:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\aspnet_merge.exe D:\home\site\repository\WebSite\obj\Release\AspnetCompileMerge\TempBuildDir -w AppViews.dll -copyattrs obj\Release\AssemblyInfo\AssemblyInfo.dll -a  
aspnet_merge : error 1003: The directory 'D:\home\site\repository\WebSite\obj\Release\AspnetCompileMerge\TempBuildDir' does not exist. [D:\home\site\repository\WebSite\WebSite.csproj]
Done Building Project "D:\home\site\repository\WebSite\WebSite.csproj" (Build;pipelinePreDeployCopyAllFilesToOneFolder target(s)) -- FAILED.

Build FAILED.

它看起来像aspnet_compiler.exe运行,但没有做什么它应该,这就是为什么TempBuildDir目录(应该是编译器的输出)不及时存在用于AspNetMerge目标。对比,与我的系统,在该目录实际上确实存在,包含标记ASPX / ASCX /等。文件,静态内容,一个precompiledApp.config文件,东西在bin目录全乱了。

It looks like aspnet_compiler.exe runs, but doesn't do what it's supposed to, which is why the TempBuildDir directory (supposed to be the output of the compiler) does not exist in time for the AspNetMerge target. Contrast that with my system, where that directory DOES in fact exist, containing the marker aspx/ascx/etc. files, static content, a PrecompiledApp.config file, and a whole mess of stuff in the bin directory.

aspnet_compiler.exe有一个 -errorstack 标志,但它不是我清楚我怎么能拿的MSBuild只是通过 .deployment <添加此/ code>文件,或者即使该应用程序是真正甚至抛出一个错误。

aspnet_compiler.exe has an -errorstack flag but it's not clear to me how I could get MSBuild to add this just via the .deployment file, or even if that app is really even throwing an error.

我可以通过Visual Studio的部署,但我的真正的喜欢利用SCM的整合,所以我可以推到我的督促分支机构,让它去。有什么建议?

I could just deploy via Visual Studio, but I would really like to take advantage of the SCM integration so I can just push to my prod branch and let it go. Any suggestions?

推荐答案

注:这在GitHub上projectkudu问题将最终使这个解决方案已经过时,但与此同时,这个问题是由于申请积压,而现在这个工作的。

Note: This GitHub issue on projectkudu will eventually make this solution obsolete, but for the meantime, that issue is filed as Backlog, and this works right now.

谢谢谢谢大卫Ebbo。有了这些信息,我能引导我的构建,为短期工作。

Thank you thank you David Ebbo. With this information, I was able to bootstrap my build to work for the short term.

首先,我下载使用诊断控制台可在Azure实例aspnet_compiler.exe在的https:// {} WEBSITE_NAME .scm.azurewebsites.net / DebugConsole 和补充说,我自己的仓库。这种方式有没有约32/64位之间的差异,等等。我在我的库重命名为 azure_aspnet_compiler.exe 的问题。

First, I downloaded the aspnet_compiler.exe from the Azure instance using the Diagnostic Console available at https://{WEBSITE_NAME}.scm.azurewebsites.net/DebugConsole and added that to my own repository. This way there's no question about any difference between 32/64-bit, etc. I renamed it to azure_aspnet_compiler.exe in my repository.

二,AspNetCompiler任务不给你更改了刀具名的选项。很难codeD,但作为虚拟财产所以它的覆写投放。所以我不得不创建自己的任务类,并将其打包在自己组装,这是我建的发行模式,也包括在我的仓库。

Second, the AspNetCompiler task doesn't give you the option to change the tool name. It's hardcoded, but as a virtual property so it's overrideable. So I had to create my own task class, and package it in its own assembly, which I built in Release mode and also included in my repository.

public class AzureAspNetCompiler : Microsoft.Build.Tasks.AspNetCompiler
{
    private string _toolName = "aspnet_compiler.exe";

    protected override string ToolName
    {
        get { return _toolName; }
    }

    public string CustomToolName // Because ToolName cannot have a setter
    {
        get { return _toolName; }
        set { _toolName = value; }
    }
}

接下来,我需要替换 ASPNET preCompile 任务的MSBuild,但我无法弄清楚如何直接做到这一点。但是,这任务不是的的东西,无论如何,所以为什么不只是后马上跑?

Next I needed to replace the AspNetPreCompile task in MSBuild, but I couldn't figure out how to do that directly. But that task wasn't doing anything anyway, so why not just run right after it?

我说这我的 Website.csproj 文件的顶部导入包含 AzureAspNetCompiler 类的DLL。请注意,路径是相对于我编辑 Website.csproj 文件。

I added this to the top of my Website.csproj file to import the DLL containing the AzureAspNetCompiler class. Note that the path is relative to the Website.csproj file I'm editing.

<UsingTask TaskName="AzureBuildTargets.AzureAspNetCompiler"
           AssemblyFile="..\DeploymentTools\AzureBuildTargets.dll" />

然后我在下面就这一权利,这基本上是偷 ASPNET preCompile 的MSBuild的目标定义从 C:\\ Program Files文件(x86)\\MSBuild\\Microsoft\\VisualStudio\\v11.0\\Web\\Transform\\Microsoft.Web.Publishing.AspNetCompileMerge.targets,与一些属性设置的东西靠近它的顶部的离开了(因为原来的任务将做到这一点对我们来说反正。)只要注意到刀具路径和<$ C的$ C> CustomToolName 在(改名) AzureAspNetCompiler 元素的谷值。

Then I added this right below it, which is basically stealing the MSBuild target definition of AspNetPreCompile from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets, with some of the property setting stuff near the top of it left out (because the original task will do that for us anyway.) Just take note of the ToolPath and CustomToolName values at the bottom of the (renamed) AzureAspNetCompiler element.

<PropertyGroup>
        <!--Relative to solution root apparently-->
        <LocalRepoDeploymentTools>.\DeploymentTools</LocalRepoDeploymentTools>
        <AzureAspnetCompilerPath>$([System.IO.Path]::GetFullPath($(LocalRepoDeploymentTools)))</AzureAspnetCompilerPath>
</PropertyGroup>

<Target Name="NoReallyAspNetPreCompile" AfterTargets="AspNetPreCompile">

<AzureAspNetCompiler
  PhysicalPath="$(_PreAspnetCompileMergeSingleTargetFolderFullPath)"
  TargetPath="$(_PostAspnetCompileMergeSingleTargetFolderFullPath)"
  VirtualPath="$(_AspNetCompilerVirtualPath)"
  Force="$(_AspNetCompilerForce)"
  Debug="$(DebugSymbols)"
  Updateable="$(EnableUpdateable)"
  KeyFile="$(_AspNetCompileMergeKeyFile)"
  KeyContainer="$(_AspNetCompileMergeKeyContainer)"
  DelaySign="$(DelaySign)"
  AllowPartiallyTrustedCallers="$(AllowPartiallyTrustedCallers)"
  FixedNames="$(_AspNetCompilerFixedNames)"
  Clean="$(Clean)"
  MetabasePath="$(_AspNetCompilerMetabasePath)"
  ToolPath="$(AzureAspnetCompilerPath)"
  CustomToolName="azure_aspnet_compiler.exe"
    />

<!--
    Removing APP_DATA is done here so that the output groups reflect the fact that App_data is
    not present
    -->
<RemoveDir Condition="'$(DeleteAppDataFolder)' == 'true' And Exists('$(_PostAspnetCompileMergeSingleTargetFolderFullPath)\App_Data')"
           Directories="$(_PostAspnetCompileMergeSingleTargetFolderFullPath)\App_Data" />


<CollectFilesinFolder Condition="'$(UseMerge)' != 'true'"
  RootPath="$(_PostAspnetCompileMergeSingleTargetFolderFullPath)" >
  <Output TaskParameter="Result" ItemName="_AspnetCompileMergePrecompiledOutputNoMetadata" />
</CollectFilesinFolder>

<ItemGroup Condition="'$(UseMerge)' != 'true'">
  <FileWrites Include="$(_PostAspnetCompileMergeSingleTargetFolderFullPath)\**"/>
</ItemGroup>

有了这个地方,一切正常,我就指望它。​​

With this in place, everything works as I would expect it to.

这篇关于不能部署precompiled,合并的web应用天青的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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