Nuget Package restore with git submodule

后端 未结 4 1993
北海茫月
北海茫月 2020-12-09 17:29

i have a project where i include 2 submodules from git. Both projects have \"nuget package restore\" enabled, the parent project too. The package folder in the two included

4条回答
  •  无人及你
    2020-12-09 18:01

    If you're using VS2015 Update 1 or later, you can convert your project to use project.json to fix this.

    In short:

    • Run Uninstall-Package -Force -RemoveDependencies for all your packages. You may wanna copy-paste your packages.config in notepad before you do this.
    • Delete packages.config from the project, save the project, unload
    • Edit the project file and remove:
      • Any referenced .props files at the top related to nuget
      • Any elements that reference a package
      • The .targets files at the bottom that reference nuget - usually starts with:
      • If your packages contain Roslyn analyzers, make sure to remove them too.
    • Save the file and relod the project

    Add project.json with:

    {
      "dependencies": {
      },
      "frameworks": {
        ".NETFramework,Version=v4.6.1": {}
      },
      "runtimes": {
        "win": {}
      }
    }
    

    Finally add your packages again, either by hand under dependencies or using Install-Package or with the nuget UI in VS.

    I've also had to remove any Microsoft.Bcl.* packages from my projects because they explicitly look for a packages.config file.

    EDIT: this (removing the Microsoft.Bcl.* packages will give you a compile-time error, even though the project will build fine, because the .targets file Microsoft.Bcl.Build adds will still look for packages.config.

    To suppress this, edit your project file and add:

    true
    

    This needs to go to the first that doesn't have a Condition attribute set. If there isn't one, just add another at the top, like:

    
        true
    
    

提交回复
热议问题