T4MVC is generating T4MVC.cs and T4MVC1.cs
Asked Answered
C

1

10
  • VS2017 15.4.1

I have been using T4MVC] for many months in this project without issue. However today each time I change a controller method it is generating two T4MVC files:

enter image description here

instead of updating T4MVC.cs which ultimately means the project wont't compile and I have to delete T4MVC1.cs.

Has anyone seen this behaviour or has some ideas of a fix?

Commute answered 20/10, 2017 at 1:53 Comment(2)
Hi! what I usually do is delete the T4MVC.cs, T4MVC1.cs and all the generated.cs files and run the custom tool again.Encephaloma
I'm seeing this too.Hypersonic
H
16

Here's the steps I do to fix it:

  • Delete T4MVC1.cs file.
  • Unload your project.
  • Edit the .csproj file.
  • Check the following tag:

    <Compile Include="T4MVC.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>T4MVC.tt</DependentUpon> </Compile>

    Make sure there's only one of these and it's T4MVC.cs. Remove T4MVC1.cs block if you have it.

  • Check the following tag:

    <None Include="T4MVC.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>T4MVC.cs</LastGenOutput> </None>

    Make sure the <LastGenOutput> is T4MVC.cs. If not, edit it to be T4MVC.cs.

  • Save the .csproj file.

  • Reload the project.
  • Rebuild
  • Make sure to check in that code so won't cause any trouble in the future.
Hospitaler answered 31/10, 2017 at 0:19 Comment(2)
Awesome solution. Worked perfectly.Commute
It worked for me, at T4MVC 4.2.4, using NET Framework 4.7.2Lorylose

© 2022 - 2024 — McMap. All rights reserved.