ERROR_EXCEPTION_WHILE_CREATING_OBJECT and MapUriToIisWebServer taskRSS

4 replies

Last post Feb 22, 2017 03:30 PM by user0c0b566b3d

  • ERROR_EXCEPTION_WHILE_CREATING_OBJECT and MapUriToIisWebServer task

    Feb 17, 2017 07:56 PM|user0c0b566b3d|LINK

    I am trying to build web deployment packages which include a parameter for "IIS Web Application Pool Name" in the Project.SetParameters.xml file. I would like to do this using MSBuild; I use Jenkins for CI/CD with MSDeploy/Powershell for deployment, and will not be building, packaging or publishing through Visual Studio.

    I would also like to leverage IIS Express for this, and not require 'regular IIS' to be installed on my build machine. So, I have selected the 'Use IIS Express' option in my projects.

    Has anyone done this successfully? Is there a trick to making it work?

    The problem I am running into is that as soon as I add "/p:IncludeIisSettings=True /p:IncludeAppPool=True" to my msbuild command, I get failures like the following on my build machines:

    "B:\workspace\job\Project\Project.vbproj" (Rebuild target) (3) ->
    (PackageUsingManifest target) -> 
      C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(3914,5): msdeploy error ERROR_EXCEPTION_WHILE_CREATING_OBJECT: Web deployment task failed. (Object of type 'manifest' and path 'manifest xml hidden' cannot be created.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXCEPTION_WHILE_CREATING_OBJECT.) [B:\workspace\job\Project\Project.vbproj]

    I have followed the link and read the page. It doesn't say anything helpful regarding this particular error. I have observed this on every build machine I've tried, on Windows 2012, R2, and 2016, with either Visual Studio 2013 or 2015 installed, regardless of patch level (including 'the latest'). It occurs via Jenkins, and if I log in as myself to execute the same commands.

    The strange thing is that my project builds correctly on my development system, i.e. I can run the exact same build commands against the same code and everything works. So, this seems to be an environmental issue, but I am having a very hard time narrowing down what it could be.

    One thing I have noticed is that the build output is slightly different with respect to the package target when building on my dev workstation vs. the build machine, and on the build machine when I pass "/p:IncludeIisSettings=true" vs. not.

    Dev workstation:

    Package:
      Invoking Web Deploy to generate the package with the following settings:
      $(LocalIisVersion) is 10
      $(DestinationIisVersion) is 10
      $(UseIis) is True
      $(IisUrl) is http://localhost:55011/
      $(IncludeIisSettings) is true
      $(_DeploymentUseIis) is True
      $(DestinationUseIis) is True
      $(IisUrl_SiteID) is 77
      $(IisUrl_SiteFriendlyName) is Project
      $(IisUrl_SiteRelativePath) is /
      $(IisServer_IisAppPoolName) is Clr4IntegratedAppPool
      $(_Destination_IisServer_IisAppPoolName) is ASP.NET v4.0
    

    Build machine with /p:IncludeIisSettings=false:

    Package:
      Invoking Web Deploy to generate the package with the following settings:
      $(LocalIisVersion) is 10
      $(DestinationIisVersion) is 10
      $(UseIis) is True
      $(IisUrl) is http://localhost:55011/
      $(IncludeIisSettings) is false
      $(_DeploymentUseIis) is False
      $(DestinationUseIis) is False

    And curiously, build machine with /p:IncludeIisSettings=true:

    Package:
      Invoking Web Deploy to generate the package with the following settings:
      $(LocalIisVersion) is 7
      $(DestinationIisVersion) is 7
      $(UseIis) is True
      $(IisUrl) is http://localhost:55011/
      $(IncludeIisSettings) is True
      $(_DeploymentUseIis) is True
      $(DestinationUseIis) is True
      $(IisUrl_SiteRelativePath) is /

    What is bothering me is that the LocalIisVersion is being set to 7 on the build machine with "/p:IncludeIisSettings=true". I have seen this, as stated above, on all of my build machines.

    If I run the build with /filelogger /flp:Verbosity=Diagnostic, I see that e.g. LocalIisVersion is set multiple times. The first time it's set correctly, via registry lookup in the GetProjectWebProperties target in Microsoft.Web.Publishing.Targets. The second time is incorrect, indirectly via the MapUriToIisWebServer task (just a few lines down) setting the IisServer_IisMajorVersion output property to 7. This latter task is also not setting other missing items like IisUrl_SiteID, _FriendlyName, etc.

    Looking online for information about MapUriToIisWebServer yields virtually nothing. As far as I can tell, it's not documented anywhere, so it's unclear what it should be doing or how it might fail. Does anyone have more information about this task?

    FWIW, I have replicated the error on a build machine with the exact same version of Visual Studio, and maybe more importantly the exact same version of the Microsoft.Web.Publishing.Tasks.dll containing the MSBuild tasks used during the build.

    I've spent the better part of 2 days trying to figure this out, and at this point I've basically given up and will either do the AppPool config by hand, or see if I can script it with Powershell. This seems like a failure though because clearly it should be possible to specify which AppPool to use as a parameter in the SetParameter file.

  • Rovastar Rovastar

    5494 Posts

    MVP

    Moderator

    Re: ERROR_EXCEPTION_WHILE_CREATING_OBJECT and MapUriToIisWebServer task

    Feb 18, 2017 04:26 AM|Rovastar|LINK

    What is this like under IIS proper? I am unclear if IIS express is causing issues here

    Troubleshoot IIS in style
    https://www.leansentry.com/
  • Re: ERROR_EXCEPTION_WHILE_CREATING_OBJECT and MapUriToIisWebServer task

    Feb 20, 2017 07:18 PM|user0c0b566b3d|LINK

    This initially failed with the same error, but then I created an empty directory and dummy application in IIS on the build server and it worked. It was still showing LocalIisVersion as 7 though, which is weird.

    That said, I got this working with IIS Express.

    Regular IIS was already installed. I did this because I was originally getting another error about a missing redirection.config and just didn't solve it correctly.

    I left out a detail in my initial post, which is that while I was seeing this error on multiple systems, the one I was working with most was a Server Core system I set up so I could test things w/o disturbing other build machines. I can install Visual Studio on Core, but I can't actually run the IDE; I think that typically the IIS Express config is created in the background when you open a solution requiring it. Running iisexpress.exe from the command line will create the config though so that's what I should have done instead of installing the IIS feature.

    Unfortunately, the result of this is the same error that I was getting before (ERROR_EXCEPTION_WHILE_CREATING_OBJECT). The problem is that the site being packaged still has to exist in the IIS Express applicationHost.config. If I copy over the applicationHost.config from my dev workstation the project will build. I'm guessing this is also something that just happens automatically if you open the solution in VS, but not if you're just building in MSBuild. We haven't seen it everywhere because most of our builds specify /p:UseIisSettings=false - probably for this reason, although no reason was documented.

    So the remaining issue is that the site has to exist in the IIS Express applicationHost.config if we want to include the App Pool config in the web deploy package. Hopefully there is a way to get site information added at build time without a lot of effort, otherwise we're checking in configs or manually updating build machines with every new service.

  • Re: ERROR_EXCEPTION_WHILE_CREATING_OBJECT and MapUriToIisWebServer task

    Feb 22, 2017 06:33 AM|Yuk Ding|LINK

    Hi user0cb566b3d,

    It is a bit hard to diagnose this kind of error. Did you create the website on the destination server. This error could occur when you didn't create the website/path with the same name on the destination server.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: ERROR_EXCEPTION_WHILE_CREATING_OBJECT and MapUriToIisWebServer task

    Feb 22, 2017 03:30 PM|user0c0b566b3d|LINK

    Hello Yuk,

    In this case, yes I believe it is because the website/path was not already created. I did not realize this was a requirement; we have historically NOT included IIS settings when building web deploy packages, so did not ever encounter this error before. Unfortunately neither verbose logging nor the link provided in the error message yield anything concrete about what might cause the error, hence the confusion.

    We've decided not to pursue including these settings, since it appears that we would have to maintain IIS or IIS Express instances manually on each build machine, which is an unreasonable burden just to get application pool settings into the web deploy package during a build. Instead, we are going to use powershell scripts at deployment time to create any missing pools pre-deployment and steer sites/apps to their designated pools post-deployment.