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

前端 未结 5 1732
情话喂你
情话喂你 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:04

    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.

    0 讨论(0)
  • 2020-12-08 02:04

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

    0 讨论(0)
  • 2020-12-08 02:04

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

    0 讨论(0)
  • 2020-12-08 02:08

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

    0 讨论(0)
  • 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.
    0 讨论(0)
提交回复
热议问题