1 year ago

#331137

test-img

Karl F

Include flat file in NuGet package and deploy into target solution

Apologies in advance, this is relatively new to me and has been asked in various ways several times...

I've been trying unsuccessfully to do the following:

  1. Create a NuGet package of my common code (can do this) which includes a specflow.json file - we'll call this common code NuGet package Base.nupkg.

  2. Reference Base.nupkg in target solution (can do this) and for specflow.json file to be copied to the target solution and visible in target solution for modification in target solution - we'll call this solution Target.sln.

The problem is, the specflow.json file is not being deployed/included in the Target.sln when Target.sln references Base.nupkg.

I have tried a number of things such as:


<ItemGroup>
  <None Include="specflow.json" PackagePath="Resources" Pack="true" />
</ItemGroup>

And:


<ItemGroup>
  <Content Include="specflow.json">
  <CopyToOutputDirectory>PreserveNewest
  </CopyToOutputDirectory>
</Content>
</ItemGroup>

And:


<ItemGroup>
    <AdditionalFiles Include="specflow.json">
  <CopyToOutputDirectory>PreserveNewest
  </CopyToOutputDirectory>
</AdditionalFiles>
</ItemGroup>

And:


<ItemGroup>
    <Content Include="specflow.json">
<Pack>true
</Pack>
  <CopyToOutputDirectory>PreserveNewest
  </CopyToOutputDirectory>
  <ContentTargetFolders>Resources\ 
  </ContentTargetFolders>
</Content>
</ItemGroup>

And:


<ItemGroup>
    <Content Include="$(MSBuildThisFileDirectory)specflow.json">
    <Pack>true
    </Pack>
    <Link>specflow.json
    </Link>
    <CopyToOutputDirectory>PreserveNewest
    </CopyToOutputDirectory>
</Content>
</ItemGroup>

I've tried following the Microsoft instructions here but no luck. I've also looked at various Stackoverflow questions such as:

Set content files to "copy local : always" in a nuget package Specifying files to add to a nuget package in .csproj file .targets file within nuget package - how to include content files into a build

The Base.nupkg is an older test unit project and has migrated from packages.config to package references. Same goes for Target.sln. Both target .Net 4.7.2.

Background as to why I want to do this is, Specflow have recently announced they are retiring Specflow+Runner. My organisations automation estate uses the html report from Specflow+Runner. Anyway, I migrated to SpecFlow.MSTest and still want an html report. So, I am also using SpecFlow LivingDoc - this requires the specflow.json file. Thus, when colleagues make use of the Base.nupkg, I would rather them not have to also manually add the specflow.json file to their target solutions, I was hoping to be able to reduce any manual steps and automatically do this when they reference Base.nupkg.

If anyone has a simple solution which consistently works, please let me know.

Thanks.

c#

visual-studio

nuget

mstest

0 Answers

Your Answer

Accepted video resources