'CSC:CSC(0,0): Error CS2001: Source file [file] could not be found.' when running a gated check in (C#)

让人想犯罪 __ 提交于 2019-12-31 05:18:10

问题


I appear to have got in a bit of a mixup with my project and whenever a gated build and check in runs, I get the following errors.....

Summary
| Phase 1
15 error(s), 602 warning(s) 
Phase 1 - 15 error(s), 602 warning(s) 
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\AssessmentCentreEpaFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\AssessmentCentreFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\AssessorEpaFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\AssessorFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\ClientSettingsFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\CustomFieldFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\EmployerFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\LoginFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\MyProfileFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\ReportFeatures.feature.cs' could not be found.
CSC:CSC(0,0): Error CS2001: Source file 'd:\a\3\s\Main\SmartEndPointAssessment\SA.SEPA.Web.UI.Selenium\Features\SettingsFeatures.feature.cs' could not be found.

All these files exist in my local path, and my solution builds and runs. Its when I try to check in I get the errors above.

Looking at the code in source control, the files don't exist. Also these files don't have the '+' icon next to them in solution explorer.

This is the folder in VSTS...

How do I get source control to recognize and add these files?

Thanks,


回答1:


According to your screenshoot and the file already checked in TFS source control. Afraid the root cause of the error you got in short currently its the TFVC limitation, from

Must not contain more than 259 Unicode characters for a single folder or file name.

Source Link: Version control paths

You have to manually tweak your file/folder structure in TFS source control to bypass this issue. From C:\Agent\_work\1\s\TestCaseProject to C:\Agent\_work\1\s\TestCasePro

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.

You could also take a look at this similar question: MSBuild error "CSC : error CS2001: Source File 'x' could not be found" with Linked Files after upgrading to Visual Studio 2012



来源:https://stackoverflow.com/questions/47517416/csccsc0-0-error-cs2001-source-file-file-could-not-be-found-when-runnin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!