为什么我的NuGet包中包含我想要转换的内容并不适用于我的.net核心控制台应用程序,我决定试着看一下不同的方法。我有一个想法是使用linqpad来加载我的nuget包并自己进行转换(因为它不是那么多)。快速谷歌搜索,我看到Nuget有一个核心包。我将其添加到我的linqpad查询中并提出此
void Main()
{
const string myPackageToInstall = "My.Custom.ServiceTemplate";
const string installPath = @"C:\Git\Path\To\PickupsScheduler";
var repositoryFactory = PackageRepositoryFactory.Default;
var sources = new List<PackageSource>{
new PackageSource("https://api.nuget.org/v3/index.json", "official"),
new PackageSource(@"C:\Program Files (x86)\Microsoft SDKs\NuGetPackages", "local"),
};
var repository = AggregateRepository.Create(repositoryFactory, sources, true);
var template = repository.FindPackage(myPackageToInstall).Dump(myPackageToInstall, 0);
var packageManager = new PackageManager(repository, installPath);
packageManager.InstallPackage(template, false, true, false);
}
然而,当我运行时,我期望通过Visual Studio 2017获得相同的输出(成功但没有添加内容文件......甚至希望内容文件可以转换,但这只是希望祝愿)运行linqpad中的代码我得到Unable to resolve dependency 'Microsoft.Extensions.Configuration (>= 2.0.0)'
我的包中的依赖项是:
我只是有几个内容文件来帮助我。为什么我得到例外的任何想法?
修改
为了清晰起见,添加我的nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>My.Custom.ServiceTemplate</id>
<version>1.0.4</version>
<authors>Robert Snyder</authors>
<owners>Robert Snyder</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Template used to build a barebone windows service with a timer</description>
<dependencies>
<group targetFramework=".NETCoreApp2.0">
<dependency id="Microsoft.Extensions.Configuration" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Configuration.Binder" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Configuration.FileExtensions" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.Configuration.Json" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.DependencyInjection" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.NETCore.App" version="2.0.0" exclude="Build,Analyzers" />
<dependency id="NLog" version="[4.5.0-rc06, )" exclude="Build,Analyzers" />
<dependency id="NLog.Extensions.Logging" version="[1.0.0-rtm-rc7, )" exclude="Build,Analyzers" />
<dependency id="PeterKottas.DotNetCore.WindowsService" version="2.0.6" exclude="Build,Analyzers" />
</group>
</dependencies>
<contentFiles>
<files include="appsettings.json" buildAction="None" copyToOutput="true"/>
<files include="nlog.config" buildAction="None" copyToOutput="true"/>
<files include="NLog.xsd" buildAction="None"/>
<files include="**/*.cs.pp" buildAction="Compile"/>
</contentFiles>
</metadata>
<files>
<file src="appsettings.json" target="content"/>
<file src="nlog.config" target="content"/>
<file src="NLog.xsd" target="content"/>
<file src="**/*.cs.pp" target="content"/>
</files>
</package>