Reputation: 27360
I have created razor class library and added
Microsoft.TypeScript.MSBuild
When I reference the project in my app using ProjectReference, it works fine.
When I reference it using PackageReference, I'm getting weird build error:
tsc : error TS18003: Build:No inputs were found in config file 'C:/Users/danie/.nuget/packages/mypackage/0.5.0/contentFiles/any/net6.0/Typescript/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["../wwwroot"]'. [C:\Projects\app\App.csproj]
How do I properly include typescript in razor class library, so that I can create valid nuget package from it?
Why is the dotnet build app.csproj
event attempting to build typescript located in nuget package?
This is my MyPackage.csproj
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>MyPackage</PackageId>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
</Project>
Upvotes: 4
Views: 436
Reputation: 11
I got this working by adding the following block to my csproj file of the razor class library.
<Target Name="RemoveTSConfigFileFromPackage" AfterTargets="CompileTypeScriptWithTSConfig">
<ItemGroup>
<Content Remove="**\tsconfig.json" />
</ItemGroup>
</Target>
This removes the tsconfig.json from the nuget package when it is built and avoids the build errors in the consuming project.
See this thread for further information: https://github.com/dotnet/aspnetcore/issues/2166
Upvotes: 1