Skip to content

MsBuild: Target TypeScriptDeleteOutputFromOtherConfigs can grab tsc.out from other Configuration #50428

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

Open
nvirth opened this issue Aug 24, 2022 · 2 comments
Assignees
Labels
Visual Studio Integration with Visual Studio
Milestone

Comments

@nvirth
Copy link

nvirth commented Aug 24, 2022

Bug Report

If you build an MsBuild project using the nuget package microsoft.typescript.msbuild, there is a target named TypeScriptDeleteOutputFromOtherConfigs which runs before CompileTypeScript.
This target aims to delete tsc...out files from other "configs" then the "current", whatever that means.

In case you build the project in Debug mode, there will be a file created:

/obj/Debug/<TargetFramework>/Tsc<RandomNumber>.out".

Now if you build this project in Release mode:

/obj/Release/<TargetFramework>/Tsc<RandomNumber>.out".

However this 2. build in Release mode will grab the previous Tsc....out from the Debug folder. It will delete all the previously built files listed in that file.

Target TypeScriptDeleteOutputFromOtherConfigs uses property $(BaseIntermediateOutputPath) which is like ...full path to project...\obj\.
I don't really understand what this Target aims to do; but couldn't it use propery $(IntermediateOutputPath) which is like obj\<Configuration>\<TargetFramework>\?
That way the above issue could be avoided.
I would think it could not cause any harm since this Tsc....out file is written by the TypeScript targets which by me always put this file into obj/Debug or obj/Release, never outside of these.

🔎 Search Terms

TypeScriptDeleteOutputFromOtherConfigs

🕗 Version & Regression Information

It is sure present in:

microsoft.typescript.msbuild v4.4.4
microsoft.typescript.msbuild v4.8.1-rc

🙁 Actual behavior

The 2. build in Release mode grabbed the previous Tsc....out from the Debug folder, and deleted all the previously built files listed in that file.
This causes the previously built files to get deleted unnecessarily.
In our project structure - which is complex and tricky - it also causes a build error.
(We have a workaround for that, we simply override target TypeScriptDeleteOutputFromOtherConfigs to do nothing; so this issue is only for the benefit of the community.)

🙂 Expected behavior

Don't really know when TypeScriptDeleteOutputFromOtherConfigs could be helpful, but it (maybe) should only scan for Tsc....out files in obj/<TargetFramework>

@RyanCavanaugh RyanCavanaugh added the Visual Studio Integration with Visual Studio label Aug 26, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 26, 2022
@sergiocastelani
Copy link

Hello @nvirth! Could you share how you override the target TypeScriptDeleteOutputFromOtherConfigs? We are experiencing the same problem here with microsoft.typescript.msbuild 5.4.5.

@sergiocastelani
Copy link

sergiocastelani commented Apr 25, 2025

Here is a tiny abstract project that reproduces the problem, causing the build to fail with the error:

\Microsoft.TypeScript.targets(712,5): error MSB3061: Unable to delete file "...". Access to the path '...' is denied

Just compile it with dotnet build -m:12 WebApplication.sln until it happens (around 20% of the times for me).
The more frameworks we try to build in parallel the bigger are the chances to hit the problem.
If we compile for only one framework, like dotnet build -f:net8.0 -m:12 WebApplication.sln, the problem won't happen.

sampleProject.zip

@RyanCavanaugh RyanCavanaugh assigned joj and unassigned HannahOshlag and minestarks Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Visual Studio Integration with Visual Studio
Projects
None yet
Development

No branches or pull requests

6 participants