5

I have tried many things today to get my build to work in Teamcity but to no avail.

Here is my setup.

I have 2 build configurations in TeamCity

  1. Build Solution
  2. Build Deployment Package Debug

Build Solution is triggered by an SVN checkin and builds the solution file. This configuration works fine.

Build Deployment Package Debug has Build Solution as its dependency and has two (MSBuild) build steps. The solution contains two websites: a front end one and an admin one. One build step builds the front end site and the other the admin site. The end result is that it puts the combined results into a zip file for deployment to the deployment server (I've not got to this bit yet).

The problem that I have is that the Build Deployment Package Debug configuration fails trying to build the first site. This is the error:

[18:40:25]Step 1/2: Web (MSBuild) (29s)
[18:40:28][Step 1/2] x.Web\x.Web.csproj.teamcity: Build target: Build (27s)
[18:40:50][x.Web\x.Web.csproj.teamcity] MvcBuildViews (4s)
[18:40:50][MvcBuildViews] AspNetCompiler (4s)
[18:40:55][AspNetCompiler] C:\BuildAgent\work\252ec59002ecc2d\x.Web\obj\debug\csautoparameterize\original\web.config(39, 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.
[18:40:55][x.Web\x.Web.csproj.teamcity] Project x.Web\x.Web.csproj.teamcity failed.
[18:40:55][Step 1/2] Step Web (MSBuild) failed

Here are Build Paramters -> System Properties

Name    Value
system._PackageTempDir   c:\deploypackage
system.Configuration     Debug
system.CreatePackageOnPublish    True
system.DeployIisAppPath  Debug
system.DeployOnBuild     True
system.PackageLocation   c:\buildshares\Debug\Debug.zip
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
  • 1
    Why the negative vote? I asked a valid question, supplying plenty of relevant details. – Sachin Kainth Apr 26 '13 at 14:41
  • Possible duplicate of [allowDefinition='MachineToApplication' error when publishing from VS2010 (but only after a previous build)](http://stackoverflow.com/questions/2566215/allowdefinition-machinetoapplication-error-when-publishing-from-vs2010-but-on) – JotaBe Oct 21 '16 at 11:25

1 Answers1

20

Here's what I did to solve this

I already had this in my project file

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

But I needed to add this also

<Target Name="AfterBuild">
    <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
</Target>

Doing this fixed the issue.

I hope this helps someone else who is working on TeamCity in the future.

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
  • 1
    There are lots of SO answers addressing this problem, but this is the only one that actually worked for me. My setup is a VS11 project that was converted from VS10, has BuildMvcViews turned on in Release only, and is now using the publish profiles. msbuild /p:DeployOnBuild was failing with the web.config error (even though it did actually publish the package...). This fixed it. – Kevin Berridge May 06 '13 at 22:08
  • 1
    Working at 1st shot! Thanks – Stefano Altieri Jun 06 '13 at 08:25
  • 2
    thanks for coming back to answer this. was tearing my hair out – spaceman Oct 22 '13 at 12:17