Visual Studio build error "Illegal characters in path"
Asked Answered
T

14

7

When I try to build my solution in Visual Studio (2010 SP1) containing a website, I get the following funny error.

------ Build started: Project: C:\...\Web\, Configuration: Debug Any CPU ------
Validating Web Site
: Build (web): Illegal characters in path.

Validation Complete

There is no more info whatsoever, even when build verbosity is set to diagnostic. I've tried to delete all the temporary files I could find, to restart everything I could. I even refetched my whole svn folder from scratch and rebuilt.. error still there. Then, quite randomly, the error disappeared. Now, about a day later, it's back.

  1. Have you ever experienced a similar behavior ? Could that be a bug of VS ?
  2. Is there a way to increase the verbosity of the Web Site validation step so that I would see more info about the error ?
Tutelage answered 10/2, 2012 at 13:49 Comment(4)
Would you mind sharing your project with me? My email is sayedha [at]{MicrosotDOTcom}.Jahnke
I'm afraid I'm not allowed to do it because of company policy. The problem is anyway that all the other guys who have exactly the same source code don't experience the problem so there's a high chance you wouldn't be able to reproduce it either. I was hoping there is some log or something where more info is available than the error I'm seeing in the build output ;)Tutelage
There is an option which may output more info on this that you can try. Go to Tools->Options->Project and Solutions and then change the MSBuild Verbosit to detailed. After that you should see a lot more info in the output window. Also if you are able to create a dummy project reproducing this please send it to me so that I can analyze it.Jahnke
Actually, my verbosity already is set to diagnostic. Although I really get a lot of output from the build, the validation outputs only the one line I have posted.Tutelage
T
7

After hours of troubleshooting I tried to debug visual studio with another instance and get to the internals of the exception. As a result, I have found the actual reason of the error :

It happens when a path containing question mark is set as a base path for the web server deployment, i.e. under

  • web project's property pages (Shift+F4)
  • tab "Start options"
  • section "Server", value "Use custom server" with a "Base URL"

An example of an invalid path is http://localhost/v8.0/xyz?user=User1. The reason is that the build process adds an additional slash at the end. Unfortunately VS is quite persistent in using the old setting value, so one has to restart it before rebuilding.

Tutelage answered 13/2, 2012 at 9:56 Comment(2)
This saved me a lot of hassle ... Intellisense wouldn't work either.Ultraism
Thanks for this. In my case, I had a rogue # at the end of the URL.Vaughn
L
3

If you are facing this problem after pulling from git , then you can follow it:

Step 1:

go to obj\Debug folder then find yourProject.csproj.FileListAbsolute.txt file open it then delete what you found in building the project. In my case i found ====>Head problem in building the project. it followed the above step , and my problem solved.

Step 2:

delete obj folder then rebuild the project.

Libbylibeccio answered 21/7, 2017 at 17:53 Comment(1)
What's the point of step 1 when step 2 deletes the folder? lol I think you meant Option 1 and Option 2 perhaps, or similar.Kahn
M
2

In my case - move solution to place with short path and use latin characters. Example:

C:/Projects/MyProject/
Merrymaker answered 22/11, 2013 at 13:58 Comment(0)
R
1

Possible solution (found here, russian language):

  1. Create folder with simple and latin-only path - for example, c:\Temp
  2. (Assuming you're using Win7) go to Control Panel->System->Advanced System Settings->Advanced->Environment Variables
  3. Change "TMP" and "TEMP" variables from "%USERPROFILE%\AppData\Local\Temp" to "C:\Temp" and press OK in all open dialogs
  4. Restart Visual Studio
Ruppert answered 10/2, 2012 at 13:56 Comment(2)
unfortunately it didn't help :(Tutelage
Only happens for me when creating a new Angular projectSeclude
M
1

I had the same problem with Visual Studio Community 2013, with Windows 8.1 (brazilian portuguese). Change of "TMP" and "TEMP" variables works fine for me.

Morphology answered 4/2, 2015 at 14:16 Comment(0)
P
1

Try deleting obj and bin folders from your root folders and rebuild.

Polik answered 10/9, 2023 at 18:38 Comment(1)
While this may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.Pastelki
C
0

I encountered the same error in VS 2013. The issue for me was on the project properties -> Web (tab) there is ProjectUrl. this was pointing to wrong url

Coyle answered 3/5, 2016 at 21:19 Comment(0)
A
0

I encountered the same symptoms with VS2015 Update 2 while working on a WIX installer. I had unloaded the .wixproj file, edited it and tried to reload it. VS claimed there was an illegal character in some path. No information was provided about the location of the illegal character.

I backed out my change and again tried to reload the project. Same problem. I found I had to close the solution and reopen it before the project would reload. Or simply restart Visual Studio.

Arezzini answered 31/5, 2016 at 16:59 Comment(0)
T
0

I was using VS 2019 community. There were two Visual studio opened. I had problem with one of them. When I was closing and re opening the visual studio it didn't solved until I closed all visual studio windows and reopened them again.

Troudeloup answered 22/5, 2020 at 1:2 Comment(0)
I
0

I had similar issue in Visual Studio 2019 when or after loading the solution file.The symptoms were -

  1. Some folders under that project were not loaded.
  2. There was a red x mark on one folder and its sub folders.
  3. There was an yellow exclaim mark on the Analyzers and Packages in the Solution Explorer.

I saw that another program (OmniSharp-vim or the OmniSharp-Roslyn server) had created a folder in the project directory with a really long name like Micorosoft Windows [Version 10.0...... git add also complained. Screen is attached below for reference.

git - Long folder name error

Once that folder was removed or deleted*, VS2019 worked normally like before.

Inainability answered 30/9, 2022 at 21:28 Comment(0)
A
0

My problem was I accidentally put my "Command Line Arguments" in the "Working Directory" in my debug settings.

Assamese answered 17/1, 2023 at 22:13 Comment(0)
I
0

I ran into this on VS 2022 Community. The issue in this case was that there were new NuGet projects added to the project, and the HintPaths all had a line feed added:

      <HintPath>
    ..\packages\Microsoft.Owin.Host.HttpListener.4.2.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>

Same thing with VSToolsPath. The developer that created this code was working on a Mac, not sure if that caused it to happen. Anyway, removing the line feeds fixed the problem.

Institutionalize answered 20/10, 2023 at 16:26 Comment(0)
F
0

In my case the issue was that my System PATH variable on windows contained "C:\Program Files\some_program_name" and also multiple such paths were listed together, separated by ";"

  1. Initially I tried with Rapid Environment Editor and made a complete mess of my PATH variables, so make sure to have a backup before going down that path with Admin access
  2. Next I made sure that none of the paths in my PATH variable were clubbed together using ";"
  3. Lastly which I believe was the deal breaker was that I noticed a environmental variable %ProgramFiles% which was associated with the path "C:/Program Files" (you can verify this by entering %ProgramFiles% in Run). As soon as I replaced all the instances of "C:\Program Files\some_program_name\..." from my PATH and replaced them with "%ProgramFiles%\some_program_name\...", the issue was finally resolved.

As an open souce developer I faced this challenge as a major hurdle as I couldn't build applications on Visual Studio 2022 with Windows 11 using CMake.
This issue might have been triggered as I had deleted my PATH variable without a backup and had to add the paths later manually which might have been the issue all this while

Word of Caution:
Always make a backup of your Environmental Variables using Registry Editor or just Ctrl+C, Ctrl+V before making any changes ro allowing any third-party application to have admin access which might chnage the PATH variable.

Funke answered 5/9, 2024 at 15:42 Comment(0)
E
-1

The solution for my was installing ASP.NET and Web package from Visual Studio Installer.

Visual Studio Installer

Elongate answered 16/5, 2024 at 18:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.