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

Visual Studio-2010Tfs

Visual Studio-2010 Problem Overview


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' could not be found".

I have created Windows applications, but in different solutions.

I cannot find any reference to this file in the web solution/project.

Any help is appreciated.

Visual Studio-2010 Solutions


Solution 1 - Visual Studio-2010

This rings a bell. I came across a similar problem in the past,

  • if you expand Properties folder of the project can you see 'AssemblyInfo.cs' if not that is where the problem is. An assembly info file consists of all of the build options for the project, including version, company name, GUID, compilers options....etc

You can generate an assemblyInfo.cs by right clicking the project and chosing properties. In the application tab fill in the details and press save, this will generate the assemblyInfo.cs file for you. If you build your project after that, it should work.

Cheers, Tarun

Update 2016-07-08:

For Visual Studio 2010 through the most recent version (2015 at time of writing), LandedGently's comment still applies:

> After you select project Properties and the Application tab as @Tarun mentioned, there is a button "Assembly Information..." which opens another dialog. You need to at least fill in the Title here. VS will add the GUID and versions, but if the title is empty, it will not create the AssemblyInfo.cs file.

Solution 2 - Visual Studio-2010

delete the assemeblyinfo.cs file from project under properties menu and rebulid it.

Solution 3 - Visual Studio-2010

Excluding the obj folder from the project (in Visual Studio), that contains the Debug & Release folders will also fix the issue.

Solution 4 - Visual Studio-2010

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.

Solution 5 - Visual Studio-2010

I got the error using TFS, my AssemblyInfo wasn't mapped in the branch I was working on.

Solution 6 - Visual Studio-2010

This solved my problem. You should select Properties, Right-Click, Source Control and Get Specific Version.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlarryrView Question on Stackoverflow
Solution 1 - Visual Studio-2010Tarun AroraView Answer on Stackoverflow
Solution 2 - Visual Studio-2010Amit N ThoreView Answer on Stackoverflow
Solution 3 - Visual Studio-2010Sanushi SalgadoView Answer on Stackoverflow
Solution 4 - Visual Studio-2010ErikEView Answer on Stackoverflow
Solution 5 - Visual Studio-2010AJ AJView Answer on Stackoverflow
Solution 6 - Visual Studio-2010Hello WorldView Answer on Stackoverflow