-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
π Search Terms
GetTypeScriptOutputForPublishing
Razor Class Library
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about this.
β― Playground Link
No response
π» Code
When building an ASPNET RCL with Razor & Typescript, there is a TypeScript MSBuild Target named GetTypeScriptOutputForPublishing which is adding the .js output files back as Content
<Content Include="@(GeneratedJavascript->'%(Identity)')" />
For example, "outDir": "tsgen" (can't be in wwwroot because of how .gitignore works with RCLs).
I tried various settings, like this:
<!--Remove generated JS and .d.ts from packing-->
<ItemGroup>
<Content Remove="tsgen\**\*.js" />
<Content Remove="tsgen\**\*.d.ts" />
<None Remove="tsgen\**\*.js" />
<None Remove="tsgen\**\*.d.ts" />
</ItemGroup>
<!--Explicitly mark them as non-packable-->
<ItemGroup>
<None Include="tsgen\**\*" Pack="false" />
</ItemGroup>
The Pack=False is occurring before GetTypeScriptOutputForPublishing, therefore TypeScript overrides my effort to remove those.
NuGet is then correctly including that content in Pack.
To remove those files after the TypeScript target, I have to add this to my project:
<!--Remove generated JS and .d.ts from packing-->
<Target Name="RemoveDistFiles" AfterTargets="GetTypeScriptOutputForPublishing">
<ItemGroup>
<Content Remove="tsgen\**" />
<None Include="tsgen\**" >
<Pack>False</Pack>
</None>
</ItemGroup>
</Target>
Then in the generated nupkg, the tsgen\ files were then no longer packed.
π Actual behavior
The GetTypeScriptOutputForPublishing inclues the removed content.
π Expected behavior
That GetTypeScriptOutputForPublishing does not include the removed content.
Additional information about the issue
The reason I need this is because I'm using WebPack to bundle the TypeScript output, but I don't need the actual TypeScript output included in the package.