jediwhale / fitsharp

Functional testing tools for .NET
http://fitsharp.github.io
Other
152 stars 73 forks source link

Only fitsharp.dll and fit.dll are included when referencing the Nuget package #193

Closed kopfsick closed 1 month ago

kopfsick commented 1 month ago

Maybe I'm doing something wrong here, but I added a reference to the fitsharp Nuget package from my project containing my test code. In the build pipeline this project gets published and Fitnesse runs tests. However, I need to manually copy all dlls other than fitsharp.dll and fit.dll as these are not included as either references or content in the nuspec.

How do I use the Nuget package in a sensible way in a build pipeline?

Of course, I can copy the contents of, in my case, the "net6.0-windows" of the Nuget package and add as content to my project, but then I would have to update it manually when moving to .NET 7/8/9.

sqeezy commented 1 month ago

With the current configuration of the nuget package only you have to use MSBuild to copy additional assemblies. this can be done by adding somehing like this to your csproj:

<ItemGroup>
  <PackageReference Include="fitsharp" Version="2024.2.27" GeneratePathProperty="true" />
</ItemGroup>

<Target Name="CopyAdditionalContent" AfterTargets="Build">
  <Copy SourceFiles="$(PkgFitsharp)\lib\net6.0-windows\Runner.dll" DestinationFolder="$(OutDir)" />
</Target>

This way you have to list the assemblies you need, but it's far less cumbersome to update. net6.0-windows could also be replaced by $(TargetFramework) in the path.

kopfsick commented 1 month ago

Thank you! I was not aware of the GeneratePathProperty flag. This method makes it a bit better, and I will do it this way. However, couldn't the other assemblies be added as content/reference in the package? Is there a downside to that? I'm not experienced with creating packages so I'm just asking :)

sqeezy commented 1 month ago

The "new" way of doing this is to have a nuget package per assembly. This could be done for fitsharp as well but the effort is kind of high.

There are also similar ways of including parts of a nuget package as reference. See this blog entry for an example. This way might be better if you actually need the reference not just the assembly in your output folder.