Please try these:
I have two solutions for you to solve the issue.
Solution 1
If you just want to install this nuget package only in new sdk projects(Net Core
and Net Standard
projects), you could use this
1) add these node in your xxx.csproj
file:
<ItemGroup>
<None Include="xxx\SwaggerIndex.html(the path of SwaggerIndex.html file in your project)" Pack="true" PackagePath="contentFiles\any\any">
<PackageCopyToOutput>true</PackageCopyToOutput>
</None>
</ItemGroup>
2) then repack your nuget project, and before you install the new version, you should first clean nuget caches first or just delete all cache files under C:\Users\xxx(current user)\.nuget\packages
Solution 2
If you want this nuget package to copy SwaggerIndex.html
file in both Net Framework
and Net Core
projects, you should use this:
1) add a file called <package_id>.props
file in your nuget project. You should note that if your nuget package named as SwaggerIndex.1.0.0.nupkg
, you should name the file as SwaggerIndex.props
file so that it will work.
In my side, I put it into a folder called build
.

2) then add these content in SwaggerIndex.props
file,
<Project>
<Target Name="CopyToOutputFolder" BeforeTargets="Build">
<ItemGroup>
<File Include="$(MSBuildThisFileDirectory)..\File\*.*"></File>
</ItemGroup>
<Copy SourceFiles="@(File)" DestinationFolder="$(TargetDir)"></Copy>
</Target>
</Project>
3) add these in xxx.csproj
file of your nuget project.
<ItemGroup>
<None Include="SwaggerIndex.html" Pack="true" PackagePath="File"></None>
<None Include="build\SwaggerIndex.props" Pack="true" PackagePath="build"></None>
</ItemGroup>
4) then repack your nuget package, before installing this new version of the nuget package, you should first clean all nuget caches first.
When you finishing installing the new version of the nuget package, click Build and the file will be copied into the main project.

Besides, there is also a similar issue about this.