Closed doxxx closed 1 year ago
My current workaround is to block default TypeScript compilation:
<PropertyGroup>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
And define a custom target which executes tsc
for each subfolder in the correct order:
<ItemGroup>
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="2.7.2" GeneratePathProperty="true">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<TypeScriptCompiler>$(PkgMicrosoft_TypeScript_MSBuild)\tools\tsc\tsc.exe</TypeScriptCompiler>
</PropertyGroup>
<Target Name="CustomTypeScriptCompile" BeforeTargets="CoreCompile">
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\Axon" Command="$(TypeScriptCompiler) --listEmittedFiles" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\Modules" Command="$(TypeScriptCompiler) --listEmittedFiles" />
</Target>
Your TypeScript version is almost five years old (January 2018). Fairly sure this won't get any support anymore.
Fair point. I can try updating the dependency.
Although I'd still like to know if this would still occur with the latest version before I put in the effort of making my code compile with the latest version.
Turns out it wasn't that hard to get my code compiling with the latest TypeScript (4.9.3). And the problem no longer presents itself with the latest TypeScript MSBuild tasks.
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
TypeScript 2.7.2 Visual Studio 2022 .NET SDK 6 & 7 installed, although the C# project targets .NET 6.
🙁 Actual behavior
I have a .NET C# project which includes two
tsconfig.json
files in two subfolders. They must be compiled in a specific order because the files in the second subfolder reference a.d.ts
file generated by the first subfolder.I have the
tsconfig.json
files defined in the correct order in my.csproj
file:When I build the project from a fresh checkout, it fails with errors from the second subfolder saying that a file which should be generated by the first subfolder is missing:
If I check the output folder, the generated file is there. If I run the build again, without cleaning the checkout, the build succeeds.
The MSBuild diagnostic log indicates that, even though the
PreComputeCompileTypeScriptWithTSConfig
target is executed for the subfolders in the correct order, theVsTsc
task is emitting errors for the second subfolder because the.d.ts
file that would be generated by the first subfolder is not present.When the subsequent
CompileTypeScriptWithTSConfig
target is executed, both subfolders compile correctly because they're executed in the correct order and actually generate the files expected.However, the overall project build fails because of the errors emitted by the
PreComputeCompileTypeScriptWithTSConfig
target.See abbreviated build log at the bottom.
🙂 Expected behavior
I would expect the compilation of multiple dependent tsconfig files to succeed without errors when the order of compilation has been defined correctly in the
.csproj
file.Logs
Abbreviated MSBuild
-v diag
log: