當我使用aspnetcompilemerge在VSTS中使用msbuild參數或發佈配置文件構建asp.net應用程序時,出現以下錯誤:使用aspnet_merge構建VSTS會導致錯誤「元素'buildProviders'無法在應用程序級別下定義」
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>
但有兩件事是奇怪這一點 -
1)我對這個錯誤信息的網絡研究顯示了部署或運行網站的問題,但我沒有部署,只是建設。
2)構建似乎成功。我可以下載工件並將其部署到本地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>
我可以縮小它在的csproj文件<MvcBuildViews>
節點。當這是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
我不能與MVC 4和Web表單項目(VS2015)重現此問題。 (將該buildProvider添加到system.web>編譯部分)。你的項目是哪一種?發佈配置文件的詳細代碼是什麼?你能用新項目重現這個問題嗎?你能在這裏分享細節構建日誌嗎? –
@ starain-MSFT感謝您的時間。我爲這個問題添加了更多信息。我創建了一個新的項目來使用設置,它似乎與''csproj設置有關。 –