When I try to build my solution in Visual Studio (2010 SP1) containing a website, I get the following funny error.
当我尝试在Visual Studio(2010 SP1)中构建包含网站的解决方案时,我得到了以下有趣的错误。
------ 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.
没有更多的信息,即使当构建详细设置为诊断。我已经试着删除我能找到的所有临时文件,尽可能地重启所有东西。我甚至从头开始重新获取我的整个SVN文件夹并重新构建。错误仍然存在。然后,相当随机的,错误消失了。现在,大约一天后,它又回来了。
- Have you ever experienced a similar behavior ? Could that be a bug of VS ?
- Is there a way to increase the verbosity of the Web Site validation step so that I would see more info about the error ?
更多回答
Would you mind sharing your project with me? My email is sayedha [at]{MicrosotDOTcom}.
你介意和我分享你的项目吗?我的电子邮件是Sayedha[at]{MicrosotDOTcom}。
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 ;)
因为公司的规定,恐怕我不能这么做。无论如何,问题是,所有其他拥有完全相同源代码的人都没有经历过这个问题,所以您也很有可能无法重现它。我希望有一些日志或其他东西,其中提供了比我在构建输出中看到的错误更多的信息;)
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.
有一个选项可以输出更多关于这方面的信息,你可以尝试一下。转到“工具”->“选项”->“项目和解决方案”,然后将MSBuild Verboite更改为“Detail”。之后,您应该会在输出窗口中看到更多信息。此外,如果您能够创建一个虚拟项目再现这一点,请发送给我,以便我可以分析它。
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.
事实上,我的冗长已经设置为诊断性的。虽然我真的从构建中获得了很多输出,但验证只输出了我发布的那一行。
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 :
经过几个小时的故障排除后,我尝试使用另一个实例调试Visual Studio,并了解异常的内部情况。结果,我找到了错误的实际原因:
It happens when a path containing question mark is set as a base path for the web server deployment, i.e. under
如果将包含问号的路径设置为Web服务器部署的基本路径,即在
- 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.
无效路径的一个示例是http://localhost/v8.0/xyz?user=User1.原因是构建过程在末尾添加了一个额外的斜杠。不幸的是,VS非常坚持使用旧的设置值,因此在重新构建之前必须重新启动它。
If you are facing this problem after pulling from git , then you can follow it:
如果你在退出git后遇到这个问题,那么你可以遵循它:
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.
转到obj\Debug文件夹,然后找到您的Project.csproj.FileListAbsolte.txt文件,打开它,然后删除您在构建项目中找到的内容。在我的例子中,我发现了建造这个项目的主要问题。按照上面的步骤,我的问题就解决了。
Step 2:
delete obj folder then rebuild the project.
删除obj文件夹,然后重建项目。
In my case - move solution to place with short path and use latin characters.
Example:
在我的情况下-移动解决方案的地方与短路径和使用拉丁字符。例如:
C:/Projects/MyProject/
Possible solution (found here, russian language):
可能的解决方案(可在此处找到俄语):
- Create folder with simple and latin-only path - for example, c:\Temp
- (Assuming you're using Win7) go to Control Panel->System->Advanced System Settings->Advanced->Environment Variables
- Change "TMP" and "TEMP" variables from "%USERPROFILE%\AppData\Local\Temp" to "C:\Temp" and press OK in all open dialogs
- Restart Visual Studio
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.
我在使用Windows 8.1(巴西葡萄牙语)的Visual Studio Community 2013上也遇到了同样的问题。更改“TMP”和“TEMP”变量对我来说很好。
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
我在VS 2013中遇到了同样的错误。对我来说,问题出在项目属性上->Web(选项卡)有ProjectUrl。这指向错误的URL
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.
在开发Wix安装程序时,我遇到了与VS2015更新2相同的症状。我已经卸载了.wixproj文件,对其进行了编辑并尝试重新加载。VS声称在某条小路上有一个非法角色。没有提供关于非法角色所在位置的信息。
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.
我收回了我的更改,并再次尝试重新加载项目。同样的问题。我发现我必须关闭解决方案并重新打开它,然后才能重新加载项目。或者简单地重新启动Visual Studio。
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.
我使用的是VS 2019社区。有两个Visual Studio打开了。我和其中一位有过节。当我关闭并重新打开VISUAL Studio时,直到我关闭所有VISUAL STUDIO窗口并重新打开它们,问题才得到解决。
I had similar issue in Visual Studio 2019
when or after loading the solution file.The symptoms were -
在加载解决方案文件时或之后,我在Visual Studio 2019中遇到了类似的问题。症状是-
- Some folders under that project were not loaded.
- There was a red x mark on one folder and its sub folders.
- 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.
我看到另一个程序(OmniSharp-vim或OmniSharp-Roslyn服务器)在项目目录中创建了一个文件夹,其名称非常长,例如Micorosoft Windows [Version 10.0. git add也抱怨道。屏幕随附于下方以供参考。
Once that folder was removed or deleted*, VS2019
worked normally like before.
一旦该文件夹被移除或删除*,VS2019就会像以前一样正常工作。
My problem was I accidentally put my "Command Line Arguments" in the "Working Directory" in my debug settings.
我的问题是我不小心把我的“命令行参数”放在了调试设置的“工作目录”中。
Try deleting obj and bin folders from your root folders and rebuild.
尝试从根文件夹中删除obj和bin文件夹,然后重新生成。
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:
我在VS 2022社区上遇到了这个。本例中的问题是,项目中添加了新的NuGet项目,并且HintPath都添加了换行符:
<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.
VSToolsPath也是如此。创建这段代码的开发人员正在Mac上工作,不确定这是否导致了这种情况的发生。无论如何,删除换行符解决了问题。
更多回答
This saved me a lot of hassle ... Intellisense wouldn't work either.
这就省去了我很多麻烦。智能感知也不会起作用。
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.
当步骤2删除文件夹时,步骤1的意义是什么?哈哈,我想你的意思是选项1和选项2,或者类似。
unfortunately it didn't help :(
不幸的是,这并没有起到作用:
Only happens for me when creating a new Angular project
只有在创建新的角度项目时才会发生
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.
虽然这可能会解决问题,包括解释这是如何以及为什么解决问题的,但这确实有助于提高你的帖子的质量,并可能导致更多的向上投票。记住,你是在为未来的读者回答问题,而不仅仅是现在提出问题的人。请编辑您的答案以添加解释,并说明适用的限制和假设。
我是一名优秀的程序员,十分优秀!