TFS 2012 Build Definition for web deployment ignores parameters defined in project files

怎甘沉沦 提交于 2019-12-06 07:40:59

问题


I'm trying to set up a TFS 2012 build definition that will build a solution and deploy several web apps within the solution. I came across this article that seems to address exactly what I'm trying to do and also seems to agree with the solution mentioned here.

So I tried implementing the build definition/project configuration as described in that article, but no matter what I do, it seems to be ignoring the parameters I put in the specific configuration property group of the csproj files which look like this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MyConfig|AnyCPU' ">
  ...
  <DeployIisAppPath>My Website Name</DeployIisAppPath>
  <MsDeployServiceUrl>MyWebServer</MsDeployServiceUrl>
</PropertyGroup>

I get the following error for each project I’m trying to deploy:

Web Deploy publish/package validating error: Missing or Invalid property value for $(MsDeployServiceUrl)

So I tried defining the MsDeployServiceUrl in the MSBuild Arguments of the build definition instead of in the csproj files. This solved the above error, but then I get this error:

The “ConcatFullServiceUrlWithSiteName” task was not given a value for the required parameter “SiteAppName”.

So its not reading the DeployIisAppPath parameter from the csproj file either, and I can’t move that to the MSBuild Arguments line because its different for each project I’m trying to deploy.

Its almost as if the deployment process is unaware of which configuration I’m building, so it can’t find the correct PropertyGroup in the csproj files to read the paramters from. However, I have specified the configuration in the “Configurations to Build” line of the build definition, and I’ve also tried adding /p:Configuration=MyConfig to the MSBuild Arguments line, and that doesn’t seem to solve the problem.

Update:

Ok, it seems like TFS doesn't recognize the Configurations defined in the solution. When I go to select "Configurations to Build" in the build definition, the drop-down list in the Configuration column in the dialog is only showing the default "Debug" and "Release". We have a half dozen or so other configurations defined in our solution that aren't showing up. I tried typing in the configuration manually, and even double checked that the spelling was correct. It builds, but doesn't use the right configuration (The wrong Web.config transform is applied). This explains why its not reading the build properties from the correct PropertyGroup in the project files.

Could this be a problem with our TFS installation/configuration? Should the solution-defined configurations show up in that drop-down list, or do you always have to manually type in custom configuration names the first time?


回答1:


I managed to solve this issue myself by removing/recreating all our solution/project configurations from Configuration Manager

Apparently something was wrong with our solution configurations that screwed up attempts to use them from a build definition. My best guess is that when they were created, they were copy/pasted from an existing configuration, but something was missed in the process and they were still somehow pointing to the original source configuration. However I was not the one who originally created them, so I can't be sure exactly what went wrong.

Anyway, I saved backups of the PropertyGroup XML for each configuration from each project file, then completely removed each configuration from the solution and each project via Configuration Manager. I then recreated each configuration, and restored the PropertyGroups in each project from my backups. Now my build definitions are reading the build properties from the correct PropertyGroups, and performing the correct transform on Web.config.




回答2:


In your build definMsDeployServiceUrltion check that the configuration you are building matches the exact same cpu I.e. "AnyCPU" or "Any CPU". Notice the extra space. Somewhere along line between different vs bersions and tfs versions a mistical space appeared or disappeared. This has caught me out before.

As a test, move the MsDeployServiceUrl property in the .csproj file out of the current propertygroup node. Then do a build. If it builds then it eill prove your concepts work but your still left with the problem tho




回答3:


I had this problem when merging from one branch to the other. The configuration information is inside the solution (.sln) file. Open that file up and see if the configuration information is correct.

Take a look at the screen-shot below. I was getting an error about PROD2|Any CPU was not correct (in the build log) and it turned out that instead of PROD2|Any CPU, the solution file had Release|Any CPU for that line. A small change and everything worked out fine.



来源:https://stackoverflow.com/questions/18219713/tfs-2012-build-definition-for-web-deployment-ignores-parameters-defined-in-proje

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!