Skip to content

TypeScript MSBuild Target named GetTypeScriptOutputForPublishing should not include the removed Content filesΒ #62948

@marqdouj

Description

@marqdouj

πŸ”Ž 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.

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions