MSBuild IIS issue

2019-06-17 18:25发布

问题:

I'm using MSBuild to package and publish an my Asp.Net MVC 3, .Net 4 Application. I've already successfully done this for an MVC 1.0, .Net 3.5 application.

Whenever I include the IIS Settings (IncludeIisSettings=true) in my .proj file I get the following build error:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(2046, 5): error MSB4044: The "EscapeTextForRegularExpressions" task was not given a value for the required parameter "Text".

回答1:

I've had the same issue on my build server.

The package would build perfectly on my development machine but would fail with the exact same error you have on my build server. For me the problem was caused by the fact that on my build machine, the application is not registered with IIS.

The problem started when I enabled local testing in IIS Express in the project and in some indirect way that enables the IncludeIisSettings=true setting you mentioned. This causes the web deployment pipeline to query IIS for the site's details. Since the build server did not have IIS 7 or IIS Express installed it could not get those settings. This ultimately leads to the error above because the parameter passed to the EscapeTextForRegularExpressions task is empty.

My solution was to set IncludeIisSettings to False in the applications .wpp.targets file (see here for an example .wpp.targets file). If you specify the settings for IIS explicitly, that should not be a problem.

I was also able to fix the build by registering the site with IIS Express using WebMatrix. Running the site in Visual Studio should have the same effect.



回答2:

The issue I had was with permissions, specifically UAC settings in Windows 7 after switching laptops.

After close inspection against my previous configuration I realized I still had the default UAC Settings. To change go to Start > Control Panel > User Accounts > User Accounts > Change User Account Control Settings. Then drag the bar all the way down to Never notify.

Here are some additional symptoms I observed which could be helpful:

When I ran msbuild locally with IncludeIisSettings=true I received the same error as in the question.

After some frustration and wrong turns I couldn't figure out why although I am an administrator I was getting permission errors in relevant areas, e.g. when setting IncludeIisSettings=false then attempting to run the deploy file I received a permission error.

Thus I decided to explore the UAC settings and find the solution.



回答3:

The solution we found to have the IncludeIisSettings=true and have a succefull build with out the "The "EscapeTextForRegularExpressions" task was not given a value for the required parameter "Text"." error was:

  • Install Visual Studio on the Build Server (already done).
  • Install IIS on the Build Server.
  • In IIS, on the Default Website, add a binding for https (port 443) and use the certificate installed by Visual Studio (IIS Express Development Certificate).


回答4:

I had to change the following in the properties\Web of the web application

in the Servers Section change it from IISExpress to Local IIS and create my vitural directory. Of Course you naturally have to to have IIS installed on your machine.