Type 'Project.Views.Home.Index' already defines a member called 'Index'

Jun 5, 2014 at 7:25 PM
I'm getting this error trying to compile my project after adding RazerGenerator and setting it up for the Index file. I'm getting the same error for 'Execute'

For some reason, the compiler seems to think the codegen folder contains both an Index.cshtml and an Index.cshtml.cs file. It doesn't. CodeGen\Views\Home\Index.cshtml shows in the error list as the file with the issue even though it doesn't exist in the codegen folder.

Index.cshtml is set to compile 'None' and 'Do not copy'

Any ideas?
Jun 11, 2014 at 2:06 PM
I'm actually getting this same exact problem. I added the extension and RazorGenerator.MSBuild and RazorGenerator.Mvc. I then ran the Enable-RazorGenerator command and when I do a build I get this error. I can't seem to find where the other defined members are at.

Jun 11, 2014 at 4:19 PM
Could you paste out the contents of the Codegened file (from obj\CodeGen) directory? It might help figuring out what's happening here.
Jun 12, 2014 at 2:02 PM
I had something like this happen, when two razor files had the same name (such as "Index.cshtml") and a razorgenerator.directives was forcing both generated classes into the same namespace.

Do you happen to use razorgenerator.directives, with a line like this?

@* Namespace: Project.Views.Home *@
Jun 12, 2014 at 2:32 PM
Edited Jun 12, 2014 at 3:34 PM
I am having this same issue. I was able to get the errors to go away by adding a "Custom Tool Namespace" value property.. however I am not sure what impact this will have.

I ended up Removing RazorGenerator.MSBuild from the csproj and now it works fine.
Jun 12, 2014 at 6:08 PM
Edited Jun 12, 2014 at 6:09 PM
Steps I took to resolve:
  1. Delete all .generated.cs files that are below each cshtml file.
  2. Remove the "RazorGenerator" Custom tool property
  3. Put back to "Content" instead of "None"
  4. Add the following to csproj file:
    <Target Name="BeforeBuild">
    <Content Remove="Views**.cshtml" />
    <None Include="Views*
    *.cshtml" />
Note: as it says in the below article, the .generated.cs files will not show in visual studio.

Jun 12, 2014 at 10:28 PM
Thanks! I haven't tried this, but I appreciate the responses.