直到大约一年前,我在这台机器上大量使用了 VS2010 的工作安装,并且仅在去年不经常使用。它过去可以很好地构建我所有的项目,但是在几个月前使用它之后,我打开它,尝试构建一个解决方案,但它无法构建,因为它似乎在准随机位置创建输出文件硬盘。
为了解决这个问题,我简单地创建了一个全新的 WinForms 项目,并且没有更改模板中的任何一行代码,我就构建了它。虽然 VS 很高兴地宣布它已建成,但我看到了同样的问题,这似乎困扰着我的真正解决方案(它实际上由大约 4-5 个解决方案组成,总共大约 160 个项目(C#,一些 C++):一个名为“目标" 与 .sln 文件在同一个文件夹中创建。在该文件夹内是另一个与解决方案名称相同的文件夹,其中是 bin 文件夹(更进一步是 Debug 和 Release)文件夹。
这是文件夹结构
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall.sln
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Debug
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Release
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Debug\Test VS after reinstall.exe
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Debug\Test VS after reinstall.pdb
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\bin
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Form1.cs
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Form1.Designer.cs
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Program.cs
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Properties
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Test VS after reinstall.csproj
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\bin\Debug
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\bin\Debug\Test VS after reinstall.vshost.exe
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\GenerateResource.read.1.tlog
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\GenerateResource.write.1.tlog
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\TempPE
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\Test VS after reinstall.csproj.FileListAbsolute.txt
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\Test VS after reinstall.exe
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\Test VS after reinstall.pdb
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\obj\x86\Debug\Test_damn_VS_after_reinstall.Properties.Resources.resources
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Properties\AssemblyInfo.cs
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Properties\Resources.Designer.cs
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Properties\Resources.resx
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Properties\Settings.Designer.cs
C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\Properties\Settings.settings
您可以看到第 1 行和第 3-8 行似乎不正确。
在我的实际解决方案中,它产生了巨大的差异,因为所有解决方案和项目都配置为构建到一个公共文件夹,并且都由相对路径配置(构建属性中的输出目标)。现在所有的参考资料都搞砸了,各种项目最终出现在硬盘驱动器的各个部分,当然没有任何东西可以正常构建。
我在 Win7SP1 x64、VS2010 Ultimate SP1 上运行。
还值得一提的是,使用预构建步骤并回显一些宏(可扩展的构建变量),我可以看到宏无法解析到正确的文件夹。有趣的是,Visual Studio 显示了一件事(项目属性、构建事件、预构建、编辑预构建、宏按钮)。那里显示以下内容:
Outdir: bin\Debug
TargetPath: C:\Users\{user}\Documents\Visual Studio 2010\Projects\Test VS after reinstall\Test VS after reinstall\bin\Debug\Test VS after reinstall.exe
但是,当构建实际运行并且预构建步骤定义为:
echo OutDir: $(OutDir)
echo TargetPath: $(TargetPath)
输出是:
------ Build started: Project: Test VS after reinstall, Configuration: Debug x86 ------
OutDir: C:\Users\{user}\documents\visual studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Debug\
TargetPath: C:\Users\{user}\documents\visual studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Debug\Test VS after reinstall.exe
Test VS after reinstall -> C:\Users\{user}\documents\visual studio 2010\Projects\Test VS after reinstall\target\Test VS after reinstall\bin\Debug\Test VS after reinstall.exe
任何想法 Visual Studio 发生了什么?