26

I'm trying to build a Web Deploy package via msbuild on a new machine and it's not working. It builds fine on other machines, but here I get the following vague error:

...\Microsoft.Web.Publishing.targets(2767,5): error : Filename: redirection.config
...\Microsoft.Web.Publishing.targets(2767,5): error : Error: Cannot read configuration file
...\Microsoft.Web.Publishing.targets(2767,5): error : 
...\Microsoft.Web.Publishing.targets(2767,5): error : Unknown error (0x80005000)

I'm not sure what 'redirection.config' is, and the line reference to the .targets file doesn't help at all.

How can I fix this?

ladenedge
  • 13,197
  • 11
  • 60
  • 117

12 Answers12

43

redirection.config is a file that lives in the IIS configuration directory, typically %SystemRoot%\System32\inetsrv\config. Here are two possibilities:

  1. The account building your project doesn't have access to the IIS config dir. This might happen if you have an automated build identity with special permissions, or you if you need to start Visual Studio as an administrator.
  2. You don't have IIS installed at all on the new machine. Check to be sure the IIS config directory, and redirection.config in particular, even exist. If not, you'll need to install IIS.
ladenedge
  • 13,197
  • 11
  • 60
  • 117
  • 4
    Running VS as Administrator takes care of the permissions problem. :) – Mike K Jul 21 '14 at 09:37
  • 5
    I needed to give access to the entire `%SystemRoot%\System32\inetsrv\config` folder...not just redirection.config – nthpixel Feb 10 '17 at 23:21
  • Also check your local Documents folder isn't being redirected by OneDrive (see my answer below) – Matt Jul 21 '23 at 10:31
4

If you receive this error when deploying with Release Managment (via IISConfig.exe) be sure that the deployment agent service account is in the local Administrators group. You may need to restart the deployment agent service.

Timothy Schoonover
  • 3,195
  • 4
  • 29
  • 44
  • That deployment agent is installed as my user, I'm a domain admin and a local admin and I still can't manage IIS websites or applications. – Brunis Feb 20 '23 at 17:40
2

Similar Issue resolved below - Might help

Insufficient Permissions Problems with MSDeploy and TFS Build 2010

2

For me, simply running visual studio as admin gave it the elevated permissions it needed to operate against this folder.

May work for others.

Adam Naylor
  • 6,172
  • 10
  • 49
  • 69
1

I got this error when I tried to use a relative path for the contentPath setting. I fixed it by settings the contentPath to the full path of the folder. Without the full path, the contentPath provider thinks it is a site path or application path and looks for it in in the IIS configuration.

Cameron Taggart
  • 5,771
  • 4
  • 45
  • 70
1

After hours of testing and troubleshooting this problem turned out to be an issue with the users profile.

This was found by logging in as myself and I didn't receive the same issue.

To fix this issue:

  1. Log into the machine as an administrator and delete the contents of the corrupt profile from C:\Users (or rename the folder to username.OLD)
  2. Open up the registry and navigate here – HKLM\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\ProfileList
  3. Find the corrupt profile and rename this to .OLD or remove it.

You can read more about it at this article.

Community
  • 1
  • 1
John
  • 19
  • 1
1

This error just appeared to me when my C# project was referencing the Microsoft.Web.Administration, Version=7.9.0.0 assembly. It looks like this assembly only works with IIS Express. For IIS, we must use Microsoft.Web.Administration, Version=7.0.0.0.

Vinicius
  • 1,601
  • 19
  • 19
  • 1
    It actually does work with IIS too, you need to give read permission to IUSR for folder %SystemRoot%\System32\inetsrv\config – AaA Dec 11 '18 at 08:32
  • @AaA, that's really interesting. Did you find any official documentation on the subject? – Vinicius Dec 11 '18 at 15:52
  • Not even one, but I tested it and it is working. Also look at comment under [this answer](https://stackoverflow.com/a/13727455/1041046) – AaA Dec 12 '18 at 06:51
0

As this is high in search engines when looking for this error, I'll post my solution.

I used Azure Pipelines to release the app to IIS and had this error. My issue was that I mistakenly used Build Agent job instead of Deployment Group job when configuring the release pipeline.

Episodex
  • 4,479
  • 3
  • 41
  • 58
0

Wow! 10 years ago and still a thing. I am publishing remote. I had to restart the "World Wide Web Publishing Service" and it worked.

Nick Abbot
  • 310
  • 3
  • 7
0

I had this problem when creating a new Web Project in Visual Studio 2022.

The issue was OneDrive hikacking the user profile and moving "Documents" from

C:\Users\[user]\Documents to C:\Users\[user]\OneDrive\Documents

Once i'd removed OneDrive and changed the documents folder back to its correct location this issue went away

Matt
  • 3,664
  • 3
  • 33
  • 39
-1

just add your powershell as administrator

-3

On server 2012 this error can be caused by UAC which needs to be disabled via the registry.

This article explains why... https://social.technet.microsoft.com/wiki/contents/articles/13953.windows-server-2012-deactivating-uac.aspx

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system

change DWORD "EnableLUA" from 1 to 0

Dean North
  • 3,741
  • 2
  • 29
  • 30