Publishing a website, excluding an aspnet_compiler link

I am having problems publishing the solution through the command line. He is interrupted periodically on various projects, but each succeeds so often. I get both a null reference error and "The application area in which the thread was running has been unloaded," which may just be a null reference with a race condition. It seems that this only happens in projects that have web services (source .asmx and WCF with or without .svc activation). The fact that he sometimes succeeds makes me think that this is not a problem with our code, although there may be some changes that we can make to mitigate the root cause (no matter what it may be).

What I tried / tested:

  • I started tfpt scorchto clean up any local changes, including the output of the assembly without success, so I know that this is not a problem with the source directories.
  • I deleted the temporary files in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files(we are on the 32-bit version) and seemed to get there, but still had problems. After another publication, the directory is still empty, so it’s probably irrelevant.
  • Using Process Monitor, I found that I was aspnet_compilerwriting %LocalAppData%\Temp\Temporary ASP.NET Files. Sometimes cleaning up these files works, or maybe I’m lucky, but then it starts to fail again. I did not notice anything else that may be relevant.
  • Make sure I have enough RAM doesn't seem to matter.
  • Run msbuild single-threaded, no difference
  • Run aspnet_compiler from the command line (get the command from the output of the MSBuild log), it always runs
  • Visual Studio ( VS 2013 2), , , framework.
  • App_Code.

, DebugDiag . :

DetailID = 1
    Count:    1
    Type:     System.NullReferenceException
    Message:  
    Stack:    
        System.Web.Compilation.DiskBuildResultCache.CacheBuildResult(System.String, System.Web.Compilation.BuildResult, Int64, System.DateTime)
        System.Web.Compilation.BuildManager.CacheBuildResultInternal(System.String, System.Web.Compilation.BuildResult, Int64, System.DateTime)
        System.Web.Compilation.WebDirectoryBatchCompiler.CacheAssemblyResults(System.Web.Compilation.AssemblyBuilder, System.CodeDom.Compiler.CompilerResults)
        System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(System.Web.Compilation.AssemblyBuilder)
        System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilderParallel(System.Collections.ICollection)
        System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(System.Collections.ICollection)
        System.Web.Compilation.WebDirectoryBatchCompiler.Process()
        System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(System.Web.Hosting.VirtualDirectory, Boolean)
        System.Web.Compilation.BuildManager.BatchCompileWebDirectory(System.Web.Hosting.VirtualDirectory, System.Web.VirtualPath, Boolean)
        System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(System.Web.Hosting.VirtualDirectory, Boolean)
        System.Web.Compilation.BuildManager.PrecompileAppInternal(System.Web.VirtualPath, System.Collections.Generic.IEnumerable`1<System.String>)
        System.Web.Compilation.BuildManager.PrecompileApp(System.Web.VirtualPath, System.Collections.Generic.IEnumerable`1<System.String>)
        System.Web.Compilation.BuildManager.PrecompileApp(System.Web.Compilation.ClientBuildManagerCallback, System.Collections.Generic.IEnumerable`1<System.String>)
        System.Web.Compilation.BuildManagerHost.PrecompileApp(System.Web.Compilation.ClientBuildManagerCallback, System.Collections.Generic.List`1<System.String>)
        [GCFrame]
        [GCFrame]
        [ContextTransitionFrame]
        [GCFrame]
        [GCFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [TPMethodFrame]
        *** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Web\3d247ccfb800c38a29cf91c27a6339da\System.Web.ni.dll
        Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Web\3d247ccfb800c38a29cf91c27a6339da\System.Web.ni.dll
        System.Web.Compilation.ClientBuildManager.PrecompileApplication(System.Web.Compilation.ClientBuildManagerCallback)
        *** ERROR: Module load completed but symbols could not be loaded for C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe
        [GCFrame]


DetailID = 2
    Count:    1
    Type:     System.NullReferenceException
    Message:  Object reference not set to an instance of an object.
    Stack:    
        [GCFrame]
        [GCFrame]
        [GCFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [GCSafeCollectionFrame]
        [TPMethodFrame]
        System.Web.Compilation.ClientBuildManager.PrecompileApplication(System.Web.Compilation.ClientBuildManagerCallback, Boolean)
        System.Web.Compilation.ClientBuildManager.PrecompileApplication(System.Web.Compilation.ClientBuildManagerCallback)
        System.Web.Compilation.Precompiler.Main(System.String[])
        [GCFrame]

, , . ?

Edit: , :

"C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe" Solution.sln /t:Build /m:1 /p:Configuration=Prod /p:Platform="Mixed Platforms" /p:DeployOnBuild=true /p:PublishProfile=Prod /p:AutoParameterizationWebConfigConnectionStrings=false /v:diag > out.txt

( ):

Target "AspNetPreCompile: (TargetId:3773)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets" from project "C:\Source\Project\Project.csproj" (target "PipelineAspNetCompileMergePhase" depends on it):
Task "AspNetCompiler" (TaskId:2474)
  Task Parameter:PhysicalPath=C:\Source\Project\obj\x86\Release\AspnetCompileMerge\Source (TaskId:2474)
  Task Parameter:TargetPath=C:\Source\Project\obj\x86\Release\AspnetCompileMerge\TempBuildDir (TaskId:2474)
  Task Parameter:VirtualPath=/ (TaskId:2474)
  Task Parameter:Debug=False (TaskId:2474)
  Task Parameter:Updateable=False (TaskId:2474)
  Task Parameter:ToolPath=C:\Windows\Microsoft.NET\Framework\v4.0.30319 (TaskId:2474)

  C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p C:\Source\Project\obj\x86\Release\AspnetCompileMerge\Source C:\Source\Project\obj\x86\Release\AspnetCompileMerge\TempBuildDir  (TaskId:2474)
  Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.34209 (TaskId:2474)
  Utility to precompile an ASP.NET application (TaskId:2474)
  Copyright (C) Microsoft Corporation. All rights reserved. (TaskId:2474)
   (TaskId:2474)
ASPNETCOMPILER : error ASPRUNTIME: Object reference not set to an instance of an object. [C:\Source\Project\Project.csproj]
  The command exited with code 1. (TaskId:2474)

Done executing task "AspNetCompiler" -- FAILED. (TaskId:2474)
Done building target "AspNetPreCompile" in project "Project.csproj" -- FAILED.: (TargetId:3773)

, , msbuild .

2: , aspnet_compiler, . gflags.exe, . NullReferenceException, System.Web. C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll.

:

internal override void CacheBuildResult(string cacheKey, BuildResult result, long hashCode, DateTime utcStart)
{
  if (!result.CacheToDisk)
    return;
  if (HostingEnvironment.ShutdownInitiated)
  {
    BuildResultCompiledAssemblyBase compiledAssemblyBase = result as BuildResultCompiledAssemblyBase;
    if (compiledAssemblyBase == null)
      return;
    this.MarkAssemblyAndRelatedFilesForDeletion(compiledAssemblyBase.ResultAssembly.GetName().Name);
  }
  else
    new PreservationFileWriter(this.PrecompilationMode).SaveBuildResultToFile(this.GetPreservedDataFileName(cacheKey), result, hashCode);
}

, : result, HostingEnvironment, compiledAssemblyBase.

+4
3

, , .

:

  • /​​

, , , , , / , .

- (, - - ). - , (, , ), .

-.Net- / , , PATH , - , , , , .

- , , .

, , - binaries/publish .. - ( ), , .

, , , , .

. , , VS2012 VS2013.

/​​

DLL . - , , , .

/ , DLL, , / .

- - , DLL, "" - , - .

, , , ; .

+1

-u , .

0
source

Source: https://habr.com/ru/post/1547470/


All Articles