代码之家  ›  专栏  ›  技术社区  ›  Jason P

使用aspnet\u merge的VSTS生成导致错误“无法在应用程序级别下定义元素‘buildProviders’”

  •  0
  • Jason P  · 技术社区  · 8 年前

    当我建立我的asp。net应用程序在VST中与aspnetcompiler一起出现在msbuild参数或发布配置文件中,我得到以下错误:

    MyProject\obj\release\aspnetcompilemerge\source\web.config(129,0): Error ASPCONFIG: The element 'buildProviders' cannot be defined below the application level.
    Process 'msbuild.exe' exited with code '1'.
    

    我相信这是指web.config的这一部分:

    <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    </buildProviders>
    

    但有两件事很奇怪-

    2) 构建似乎成功了。我可以下载工件并将其部署到一个on-prem web服务器上,并且输出似乎已经按照我的发布配置文件中的定义进行了合并。

    如何解决这个问题?

    编辑-我能够在一个新的MVC项目中再现这种情况。

    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <PrecompileBeforePublish>True</PrecompileBeforePublish>
        <EnableUpdateable>False</EnableUpdateable>
        <DebugSymbols>False</DebugSymbols>
        <WDPMergeOption>MergeAllOutputsToASingleAssembly</WDPMergeOption>
        <UseMerge>True</UseMerge>
        <SingleAssemblyName>buildprovidertest.PublishedOutput</SingleAssemblyName>
        <DeleteAppCodeCompiledFiles>True</DeleteAppCodeCompiledFiles>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <publishUrl>C:\Publish\buildprovidertest</publishUrl>
        <DeleteExistingFiles>True</DeleteExistingFiles>
      </PropertyGroup>
    </Project>
    

    <MvcBuildViews> csproj文件中的节点。那是什么时候 true ,我收到此错误消息。如果我设置为 false ,构建成功。

    2017-07-31T13:43:32.4134567Z   Adding file (d:\a\1\s\buildprovidertest\obj\Release\Package\PackageTmp\Web.config).
    2017-07-31T13:43:32.4134567Z   Adding ACL's for path (d:\a\1\s\buildprovidertest\obj\Release\Package\PackageTmp)
    2017-07-31T13:43:32.4134567Z   Adding ACL's for path (d:\a\1\s\buildprovidertest\obj\Release\Package\PackageTmp)
    2017-07-31T13:43:32.4204577Z   Adding declared parameter 'IIS Web Application Name'.
    2017-07-31T13:43:32.4224576Z   Adding declared parameter 'DefaultConnection-Web.config Connection String'.
    2017-07-31T13:43:32.4904577Z   Successfully executed Web deployment task.
    2017-07-31T13:43:32.4984583Z   Package "buildprovidertest.zip" is successfully created as single file at the following location:
    2017-07-31T13:43:32.4984583Z   file:///d:/a/1/a
    2017-07-31T13:43:32.4984583Z   To get the instructions on how to deploy the web package please visit the following link:
    2017-07-31T13:43:32.4984583Z   http://go.microsoft.com/fwlink/?LinkId=124618
    2017-07-31T13:43:32.5184584Z GenerateSampleDeployScript:
    2017-07-31T13:43:32.5184584Z   Sample script for deploying this package is generated at the following location:
    2017-07-31T13:43:32.5184584Z   d:\a\1\a\buildprovidertest.deploy.cmd
    2017-07-31T13:43:32.5184584Z   For this sample script, you can change the deploy parameters by changing the following file: 
    2017-07-31T13:43:32.5184584Z   d:\a\1\a\buildprovidertest.SetParameters.xml
    2017-07-31T13:43:32.5184584Z PipelineDeployPhase:
    2017-07-31T13:43:32.5184584Z   Publish Pipeline Deploy Phase
    2017-07-31T13:43:32.6134809Z CleanupForBuildMvcViews:
    2017-07-31T13:43:32.6134809Z   Deleting file "obj\Release\TransformWebConfig\assist\Web.config".
    snip
    2017-07-31T13:43:32.6384579Z   Deleting file "obj\Release\Package\PackageTmp\Views\Shared\_LoginPartial.cshtml".
    2017-07-31T13:43:32.6384579Z MvcBuildViews:
    2017-07-31T13:43:32.6384579Z   C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p d:\a\1\s\buildprovidertest 
    2017-07-31T13:43:37.9922053Z ##[error]buildprovidertest\obj\release\aspnetcompilemerge\source\web.config(21,0): Error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.
    2017-07-31T13:43:37.9922053Z d:\a\1\s\buildprovidertest\obj\release\aspnetcompilemerge\source\web.config(21): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. [d:\a\1\s\buildprovidertest\buildprovidertest.csproj]
    2017-07-31T13:43:37.9922053Z Done Building Project "d:\a\1\s\buildprovidertest\buildprovidertest.csproj" (default targets) -- FAILED.
    2017-07-31T13:43:37.9932061Z Done Building Project "d:\a\1\s\buildprovidertest.sln" (buildprovidertest target(s)) -- FAILED.
    2017-07-31T13:43:37.9932061Z 
    2017-07-31T13:43:37.9932061Z Build FAILED.
    2017-07-31T13:43:38.0012046Z 
    2017-07-31T13:43:38.0012046Z "d:\a\1\s\buildprovidertest.sln" (buildprovidertest target) (1) ->
    2017-07-31T13:43:38.0012046Z "d:\a\1\s\buildprovidertest\buildprovidertest.csproj" (default target) (2) ->
    2017-07-31T13:43:38.0012046Z (MvcBuildViews target) -> 
    2017-07-31T13:43:38.0012046Z   d:\a\1\s\buildprovidertest\obj\release\aspnetcompilemerge\source\web.config(21): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. [d:\a\1\s\buildprovidertest\buildprovidertest.csproj]
    2017-07-31T13:43:38.0012046Z 
    2017-07-31T13:43:38.0012046Z     0 Warning(s)
    2017-07-31T13:43:38.0012046Z     1 Error(s)
    2017-07-31T13:43:38.0012046Z 
    2017-07-31T13:43:38.0012046Z Time Elapsed 00:00:55.07
    2017-07-31T13:43:38.1372049Z ##[error]Process 'msbuild.exe' exited with code '1'.
    2017-07-31T13:43:38.1882046Z ##[section]Finishing: Build solution
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   starian chen-MSFT    8 年前

    有了这个设置,你也不能通过VS 2015发布它。

    <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
        <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
      </Target>
      <Target Name="AfterBuild">
        <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
      </Target>
    

    相关线程: TeamCity Build Failure