0

When I build my asp.net application in VSTS with aspnetcompilemerge either in an msbuild argument or a publish profile, I get the following error:

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

I believe this is in reference to this section of the web.config:

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

But two things are odd about this -

1) My internet research on that error message shows issues with deploying or running a website, but I'm not deploying, only building.

2) The build does seem to succeed. I'm able to download the artifact and deploy it to an on prem web server, and the output appears to have been merged as defined in my publish profile.

Any ideas how to resolve this?

EDIT - I was able to reproduce this situation in a new MVC project.

Publish profile:

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

I was able to narrow it down to the <MvcBuildViews> node in the csproj file. When that is true, I get this error message. If I set it to false, the build succeeds.

Posting the entire build log exceeds the character limit for stackoverflow, but here's the end:

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
Jason P
  • 26,984
  • 3
  • 31
  • 45
  • I can’t reproduce this issue with the MVC 4 and Web form projects (VS2015). (Add that buildProvider to system.web>compilation section). Which type of your project? What’s the detail code of publish profile? Can you reproduce this issue with a new project? Can you share the detail build log here? – starian chen-MSFT Jul 31 '17 at 02:50
  • @starain-MSFT Thanks for your time. I added more info to the question. I created a new project to play with settings and it seems to be related to the `` csproj setting. – Jason P Jul 31 '17 at 14:03

1 Answers1

1

With that setting, you can’t publish it through VS 2015 too.

Add this code to project file (xx.csproj):

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

Related thread: TeamCity Build Failure

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53