[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T4.BuildTools fails to preprocess template in non-root direcftory #191

Open
deniszykov opened this issue Aug 27, 2024 · 2 comments
Open

Comments

@deniszykov
Copy link

Transform seems fine, but preprocess fails for non-root paths.
It seems no directory existence check is made before writing a output file.

Include item:

<T4Preprocess Include="CodeGeneration\CSharp73\CSharp73GameDataGenerator.tt"/>

Error message:

0>CSharp73GameDataGenerator.cs(-1,-1): Error  : Internal error: System.IO.DirectoryNotFoundException: Could not find a part of the path '\projects\ProjectName\src\ProjectName\obj\Release\net472\TextTransform\CodeGeneration\CSharp73\CSharp73GameDataGenerator.cs'.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding)
   at Mono.TextTemplating.Build.TextTransformProcessor.WriteOutput(MSBuildTemplateGenerator generator, String outputFile, String outputContent, Encoding encoding) in /_/Mono.TextTemplating.Build/TextTransformProcessor.cs:line 184
@UweLesta
Copy link

The following works for me with package <PackageReference Include="T4.BuildTools" Version="3.0.0" /> :
(windows Vs2022 net8.0)

	<PropertyGroup>
		<TransformOnBuild>true</TransformOnBuild>
		<T4DefaultNamespace>EfScaffolding.CodeTemplate.EFCore</T4DefaultNamespace>
		<TransformOutOfDateOnly>false</TransformOutOfDateOnly>
		<UseLegacyT4Preprocessing>true</UseLegacyT4Preprocessing>
	</PropertyGroup>

	<ItemGroup>
		<T4Preprocess Include="EfScaffolding\CodeTemplates\EFCore\DbContext.t4" />
		<T4Preprocess Include="EfScaffolding\CodeTemplates\EFCore\EntityTypeModel.t4" />
	</ItemGroup>
	
	<ItemGroup>
		<Compile Update="EfScaffolding\CodeTemplates\EFCore\*.cs">
			<DependentUpon>%(Filename).t4</DependentUpon>
			<DesignTime>True</DesignTime>
			<AutoGen>True</AutoGen>
		</Compile>
	</ItemGroup>

@deniszykov
Copy link
Author

Thanks @UweLesta, workaround works.
Still, bug exists and should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants