在Nuget软件包中包含(DLL)文件

时间:2019-02-12 07:20:32

标签: c# dependencies nuget

我在一个支持使用Nuget软件包上传自定义代码的平台上工作。该文档不是很好,我还无法找到更好的解决方案来处理依赖项。当我上传软件包时,平台将运行nuget restore。但是,在大多数情况下,它找不到软件包,当然也找不到本地软件包。这导致我创建了一个自定义nuspec文件,其中包含我的所有文件,并且它们被包含在nuget包中。在平台上工作正常。然而,该解决方案易于出错并且难以管理。它很容易混淆文件路径,而忘记添加某些软件包。

 <?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>ASystem.CustomerSystem</id>
    <version>1.0.7</version>
    <authors>ME</authors>
    <owners>ME</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>A nuget package with custom tasks for the platform</description>
    <tags>ME</tags>
    <dependencies>
      <group targetFramework=".net471">
        <dependency id="System.ServiceModel.Http" version="4.5.3" exclude="Build,Analyzers" />
        <dependency id="System.ServiceModel.Primitives" version="4.5.3" exclude="Build,Analyzers" />
        <dependency id="Microsoft.IdentityModel.JsonWebTokens" version="5.4.0" exclude="Build,Analyzers" />
        <dependency id="Microsoft.IdentityModel.Logging" version="5.4.0" exclude="Build,Analyzers" />
        <dependency id="Microsoft.IdentityModel.Tokens" version="5.4.0" exclude="Build,Analyzers" />
        <dependency id="Newtonsoft.Json" version="12.0.1" exclude="Build,Analyzers" />
        <dependency id="System.IdentityModel.Tokens.Jwt" version="5.4.0" exclude="Build,Analyzers" />
      </group>
      <group targetFramework=".NETStandard2.0">
        <dependency id="ASystem.WebStandard" version="1.0.0.0" exclude="Build,Analyzers" />
        <dependency id="System.ServiceModel.Http" version="4.5.3" exclude="Build,Analyzers" />
        <dependency id="System.ServiceModel.Primitives" version="4.5.3" exclude="Build,Analyzers" />
        <dependency id="Microsoft.IdentityModel.JsonWebTokens" version="5.4.0" exclude="Build,Analyzers" />
        <dependency id="Microsoft.IdentityModel.Logging" version="5.4.0" exclude="Build,Analyzers" />
        <dependency id="Microsoft.IdentityModel.Tokens" version="5.4.0" exclude="Build,Analyzers" />
        <dependency id="Newtonsoft.Json" version="12.0.1" exclude="Build,Analyzers" />
        <dependency id="System.IdentityModel.Tokens.Jwt" version="5.4.0" exclude="Build,Analyzers" />
      </group>
    </dependencies>
  </metadata>
  <files>
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\net471\ASystem.CustomerSystem.dll" target="lib\net471\ASystem.CustomerSystem.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\net471\ASystem.WebStandard.dll" target="lib\net471\ASystem.WebStandard.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\net471\Microsoft.IdentityModel.JsonWebTokens.dll" target="lib\net471\Microsoft.IdentityModel.JsonWebTokens.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\net471\Microsoft.IdentityModel.Logging.dll" target="lib\net471\Microsoft.IdentityModel.Logging.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\net471\Microsoft.IdentityModel.Tokens.dll" target="lib\net471\Microsoft.IdentityModel.Tokens.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\net471\System.IdentityModel.Tokens.Jwt.dll" target="lib\net471\System.IdentityModel.Tokens.Jwt.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\netstandard2.0\ASystem.CustomerSystem.dll" target="lib\netstandard2.0\ASystem.CustomerSystem.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\ASystemTaskMetadata.json" target="ASystemTaskMetadata.json" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\netstandard2.0\ASystem.WebStandard.dll" target="lib\netstandard2.0\ASystem.WebStandard.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\netstandard2.0\Microsoft.IdentityModel.JsonWebTokens.dll" target="lib\netstandard2.0\Microsoft.IdentityModel.JsonWebTokens.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\netstandard2.0\Microsoft.IdentityModel.Logging.dll" target="lib\netstandard2.0\Microsoft.IdentityModel.Logging.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\netstandard2.0\Microsoft.IdentityModel.Tokens.dll" target="lib\netstandard2.0\Microsoft.IdentityModel.Tokens.dll" />
    <file src="C:\Project\ASystem\ASystem.Customer\ASystem.CustomerSystem\bin\Debug\netstandard2.0\System.IdentityModel.Tokens.Jwt.dll" target="lib\netstandard2.0\System.IdentityModel.Tokens.Jwt.dll" />
  </files>
</package>

如您所见,我想同时支持Standard 2.0和.Net471。我必须手动包括所有我引用的DLL。这使我想到了一些问题:

1。是否可以直接在csproj文件中引用这些文件?它更易于管理imo,仅依靠publish选项就很整洁。据我所知,运行发布会从csproj文件创建一个新的nuspec文件并将其打包。

2。是否有针对csproj或nuspec文件的指令,该指令自动包含所有DLLS?还是至少可以使它在例如我的示例中的绝对文件路径上更具可读性并且不可靠?

0 个答案:

没有答案