Source file 'Properties\AssemblyInfo.cs' could not be found

前端 未结 5 1752
情话喂你
情话喂你 2020-12-08 01:31

I\'m running VS2010. When I open my web solution & attempt to build, the build fails with the error \"CSC(0,0): error CS2001: Source file \'Properties\\AssemblyInfo.cs\

5条回答
  •  无人及你
    2020-12-08 02:23

    This can also happen if you have a solution containing the project open in Visual Studio, then use your source control software to change to an older commit that does not contain that project. Normally, this would be obvious as all the project files would disappear as well. But, if it's a new project with very few or no files at all, it could be puzzling to see that just this one file, AssemblyInfo.cs, is missing. And, it's more likely you'd be messing about with an AssemblyInfo.cs when a project is new, so might miss that another file or two is also missing.

    The cure is to do any of the following:

    • Fetch the missing AssemblyInfo.cs and any other missing files from another commit, taking care to manage and save your .csproj file so the referenced files don't vanish from the project—perhaps by adding and removing a random .cs file to cause changes to need to be saved (since visual studio thinks the .csproj file has been saved when it hasn't).
    • Close and reopen Visual Studio without saving (if the project file isn't really saved) or remove the project. Removing makes sense if you didn't actually want the project created yet, since it will be created in the later commit.
    • Recreate the AssemblyInfo.cs file manually. Just copy another project, and change the details, especially the GUID so it matches the one from the .sln file.

提交回复
热议问题