Submodules in dotnet framework

by on under programming
2 minute read

Using Git Submodules in dotnet framework

You will need to migrate all the projects involved away from packages.config to project.json. See below project type specific instructions.

You will need to clone the Git Submodules into a folder. I use the solutions root folder /lib. See: core/src/develop/lib/

You can then reference the Submodule project relative to the solution. Ensure it’s relative path otherwise it wont work on other peoples machines.

How to migrate package.config to project.json

If I recall correctly this is due to NuGet deps were previously restored per a project instead of per a solution.

Official wiki page but a more manual approach: Converting a csproj from package.config to project.json

A related blog post on the topic: Oren Codes - Project.json all the things

Powershell script to automate it: nugetprojectjson

Example command for a dotnet framework 4.6.1 project: .\create_project_json.ps1 -r -f net461

A couple fixes and issues I found for you to be aware of:



Project types

Dotnet standard 2.0 class library and dotnet framework 4.6.1 MVC web

This assumes a dotnet standard 2.0 class library with Project.csproj package references and a dotnet framework 4.6.1 MVC web project with package.config.

  1. Migrate the dotnet framework project to project.json.
  2. If you plan to consume a dotnet standard 2.0 library in a dotnet framework 4.6.1 project you will need Visual Studio 2017 or newer.
  3. If it’s a MVC web project you will need to run the project, stop it and then double click the binding redirect warning to update the Web.Config automatically with the correct bindings.

Dotnet framework 4.6.1 class library and dotnet framework 4.6.1 MVC web

This assumes two dotnet framework 4.6.1 projects with package.config.

  1. Migrate both projects to project.json.
  2. You wont need binding redirects unless you have a version mismatch in NuGet deps.

Dotnet framework 4.6.1 PackageReference format

Dotnet standard 2.0 class library and dotnet core web 2.0+

This assumes a dotnet standard 2.0 class library and a dotnet core web project with Project.csproj.

Works fine without all this mumbo jumbo. See example: Core/Core.csproj

Framework compatibility

Some of these issues are around dotnet framework 4.6.1 not being “fully” compatible with dotnet standard 2.0. Despite the .NET implementation support suggesting otherwise. Dotnet framework 4.7.2 is supposed to be fully supported.

See point 2 under the .NET implementation support table for more information.

This is more to do with the binding redirects and versions of dependencies as dotnet framework 4.6.1 actually “implements .NET Standard 1.4”. However it will support up to dotnet standard 2.0 with binding redirects.

Azure DevOps/VSTS CI

You will need to ensure clone Submodules is part of the continuous integration pipeline.

Potential roadblocks

Git, Submodules, dotnet, core, standard, framework, NuGet
comments powered by Disqus