MSBuild错误"CSC:错误CS2001:找不到源文件'x'"升级到Visual Studio 2012后使用链接文件 [英] MSBuild error "CSC : error CS2001: Source File 'x' could not be found" with Linked Files after upgrading to Visual Studio 2012

查看:171
本文介绍了MSBuild错误"CSC:错误CS2001:找不到源文件'x'"升级到Visual Studio 2012后使用链接文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在自动升级.net 4.0 Web应用程序的项目文件以使其与Visual Studio 2012一起使用后,一切开始都是正常的,但是在编译时出现了很多这样的错误:

说明:找不到源文件'.. \ .. \ .. \ .. \.\\ File Path'

文件:CSC

当在"VS2012的开发人员命令提示符"中尝试使用MSBuild进行构建时(仅传递项目完整路径,没有其他参数)时,我遇到了基本上相同的错误:

"CSC:错误CS2001:找不到源文件'x'"

所有错误均涉及位于我们代码分支不同深度的其他Web应用程序项目中的链接文件(aspx,cs等)(这就是为什么所有".... \"在路径的开头)

对我来说,文件长度似乎有问题,我前一段时间在使用MSBuild在CI服务器上构建项目时遇到了相同的问题,我可以通过操作在使用自定义脚本构建项目文件之前,无需移动分支或减少项目的深度,我不必移动任何东西,当时的重要事情是使用Visual Studio 2010的开发人员可以进行编译一切都没有问题.我由此了解到,使用MSBuild进行编译/构建与使用DevEnv/VS进行编译/构建有所不同,例如,MSBuild不支持构建Setup项目,而DevEnv则支持.

由于VS 2012/DevEnv 2012现在正在发生这种情况,加上VS 2012不再支持安装项目(例如msbuild),加上VS/DevEnv的文件长度存在相同的问题,因此VS 2012看起来像最终在幕后使用msbuild或更紧密地集成在一起,但是我没有找到任何文章可以证实这一点.

更改分支机构/更改项目的深度,由于以下几个原因(大型代码库,大量项目,风险,时间,工作量等),目前无法选择.

有人在Visual Studio 2012中有替代解决方案或针对此问题的修复程序吗?

此致

PD:顺便说一句,我已经检查了此帖子链接文件的MSBuild错误,但是喜欢我说过,在更改路径之前,它现在不是选择.

解决方案

我知道我前一阵子做了这个问题,但是出于什么价值,我们最终寻求的方法是:

  • 找到报告时间过长的文件.
  • 通过减少名称的长度和/或减少这些文件的完整路径长度 容器文件夹的长度或减少文件夹的嵌套 等级.因此,减少了完整的路径长度.
  • 在从属项目上更新更改的文件的链接(重新链接).

这解决了开发人员工作站以及使用MSbuild的CI/Deploy服务器上Visual Studio 2012的问题.

就我的情况而言,与移动完整的项目/解决方案以降低其文件夹嵌套级别或减少文件夹名称,以及必须更新从属项目/解决方案的所有引用相比,此方法的风险较小,并且隐含的精力更少.

After automatically upgrading the project file for a .Net 4.0 web application to work with Visual Studio 2012 everything worked ok at first however when compiling I got lots of errors like this:

Description : Source File '..\..\..\..\..\File Path' could not be found

File : CSC

And when trying to build using MSBuild (passing just the project full path, with no additional parameters) in the "Developer Command Prompt for VS2012" I got basically the same errors:

"CSC : error CS2001: Source File 'x' could not be found"

All errors refer to Linked Files (aspx,cs,etc) located in other web applications projects located at a different deep in our code Branch (that's why all the '....\' at the beginning of the paths)

To me it looks like a problem with the file Length, I had the same problem a while ago when building the projects on our CI server using MSBuild, I was able to manage it by manipulating the project files before building them using a custom script without the need to move the branch around or reduce the deep of the projects, I didn't have to move anything, the important thing at the time it was that developers using Visual Studio 2010 could compile everything without problems. I learned by this that compiling/Building with MSBuild was different that with DevEnv/VS, and for example MSBuild didn't support building Setup projects and DevEnv did.

Since this is happening now with VS 2012/DevEnv 2012 , plus that VS 2012 doesn't support setup projects anymore (like msbuild), plus VS/DevEnv have the same problem with the file length, it looks like VS 2012 its finally using msbuild under the hood or are more tightly integrated, however I didn't find any article to confirm this.

Changing the branch structure/changing the deep of the projects it’s not an option right now due to several reasons (large code base, high number of projects, risk, timing, effort, etc.).

Does someone have an alternative solution or a fix for this issue in Visual Studio 2012?

Regards,

P.D.: BTW I already checked this post MSBuild error with linked files but like I said before changing the paths its not an option right now.

解决方案

I know that i did this question a while ago but for what is worth, The approach that we finally went for was:

  • Locating the files that were reported as too long.
  • Reduce the full path length of those files, by reducing the length of the name and/or the length of the container folder or reducing the folder nesting level. Therefore reducing the full path length.
  • Update the links of the changed files (re-linking) on the dependant projects.

This solved the problem with Visual Studio 2012 on developers workstations and on our CI/Deploy servers that used MSbuild.

For my scenario this approach was less risky,and implied less effort than moving complete projects/solutions to reduce their folder nesting level or reducing the folder names, and have to update all the references of the dependant project/solutions.

这篇关于MSBuild错误"CSC:错误CS2001:找不到源文件'x'"升级到Visual Studio 2012后使用链接文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆