Target specific dependencies NuGet

后端 未结 1 1691
梦谈多话
梦谈多话 2021-01-23 12:35

I have the following dependencies in my .nuspec file:


        
          
           


        
1条回答
  •  礼貌的吻别
    2021-01-23 13:20

    After thoroughly reading

    https://docs.microsoft.com/en-us/nuget/reference/nuspec#dependencies-element

    https://docs.microsoft.com/en-us/nuget/reference/target-frameworks

    https://docs.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/nuget-manual

    it can be summed up to:

    Version 2.0+

    As an alternative to a single flat list, dependencies can be specified according to the framework profile of the target project using elements within .

    Each group has an attribute named targetFramework and contains zero or more elements. Those dependencies are installed together when the target framework is compatible with the project's framework profile.

    The element without a targetFramework attribute is used as the default or fallback list of dependencies. See Target frameworks for the exact framework identifiers.

    Therefore in my case it would be:

        
           
              
              
              
              
              
              
           
           
              
              
              
            
        
    

    This way when I'm installing the package on the .netstandard project it will check the targetFramework and see that it's not MonoAndroid and it will fallback to the element without a targetFramework and use only Dep1, Dep2 and Dep3. For the MonoAndroid10 project it will do the same and use all of them.

    0 讨论(0)
提交回复
热议问题