我已经创建了一个nuget包,我需要在appsettings.json中添加一个部分,或者添加我自己的复制到应用程序中的配置文件,但是我无法弄清楚如何。
I want this:
{
"mysection" :
{
"value1": "value,
"value2": "value"
}
}
要添加到配置文件中,或者在下载nuget包时包含要复制的文件。我们正在使用visual studio teamservices来构建和托管nuget包。
答案 0 :(得分:2)
<ItemGroup>
<EmbeddedResource Include="settings.json" Pack="true">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
答案 1 :(得分:0)
您想编辑nuspec文件并使用files元素并在那里添加文件。
i = 0
while i < 20:
fd_player = daily_dfs['dfsEntries'][0]['dfsRows'][i]['player']
salary_fd = daily_dfs['dfsEntries'][0]['dfsRows'][i]
fd_last_name = fd_player['LastName']
fd_first_name = fd_player['FirstName']
fd_player_salary = salary_fd['salary']
dk_player = daily_dfs['dfsEntries'][1]['dfsRows'][i]['player']
salary_dk = daily_dfs['dfsEntries'][1]['dfsRows'][i]
dk_last_name = dk_player['LastName']
dk_first_name = dk_player['FirstName']
dk_player_salary = salary_dk['salary']
writer.writerow([fanduel, fd_first_name, fd_last_name, fd_player_salary, draftkings, dk_first_name, dk_last_name,
dk_player_salary])
print(
fanduel, fd_first_name, fd_last_name, fd_player_salary, draftkings, dk_first_name, dk_last_name, dk_player_salary)
i+=1
如果你在NuGet 4+上使用NuGet 3.3+或PackageReference,你应该使用contentFiles elemenet。
<files>
<file src="myConfig.json" target="Content" />
</files>
文档建议指定这两个元素以实现最大兼容性。您可以阅读更多here