将平面文件包含在 NuGet 包中并部署到目标解决方案中
提前道歉,这对我来说相对较新,并且已多次以各种方式询问过...
我一直在尝试执行以下操作但未成功:
创建我的常用代码的 NuGet 包(可以执行此操作),其中 包含一个specflow.json文件 - 我们将这个通用代码称为NuGet 包Base.nupkg。
参考目标解决方案中的Base.nupkg(可以做到这一点)和 要复制到目标解决方案并可见的 specflow.json 文件 在目标解决方案中修改目标解决方案 - 我们将调用 这个解决方案Target.sln。
问题是,当 Target.sln 引用 Base.nupkg 时,specflow.json 文件未部署/包含在 Target.sln 中。
我尝试了很多事情,例如:
<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>
我尝试按照 Microsoft 说明进行操作 这里 但没有运气。我还查看了各种 Stackoverflow 问题,例如:
在 nuget 包中将内容文件设置为“复制本地:始终” 指定要添加到 . csproj 文件 nuget 包中的 .targets 文件- 如何将内容文件包含到构建中
Base.nupkg 是一个较旧的测试单元项目,已从packages.config 迁移到包引用。 Target.sln 也是如此。两者都针对 .Net 4.7.2。
我想要这样做的背景是,Specflow 最近宣布他们将停用 Specflow+Runner。我的组织自动化资产使用 Specflow+Runner 的 html 报告。不管怎样,我迁移到 SpecFlow.MSTest 并且仍然想要一份 html 报告。因此,我还使用 SpecFlow LivingDoc - 这需要 specflow.json 文件。因此,当同事使用 Base.nupkg 时,我希望他们不必手动将 specflow.json 文件添加到他们的目标解决方案中,我希望能够减少任何手动步骤,并在他们引用时自动执行此操作基础.nupkg。
如果有人有一个始终有效的简单解决方案,请告诉我。
谢谢。
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:
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.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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论