Search code examples
visual-studio.net-corebuilddeveloper-tools

Visual Studio and dotnetcore standardization across development team


This is a rough description of the current state of things on my development team:

  • Each developer has their own computer for day-to-day work.
  • We have a server that performs all builds and executes our unit/functional tests. All "official builds" come from this one machine.
  • Most developers have VS2019, while a subset use VS2022.
  • When I look inside C:\Program Files\dotnet\sdk, we all have a mishmash of various versions installed. One developer's list of versions could be completely different compared to another developer.

Occasionally (but somewhat rarely), someone will make a change that causes something in the .sln or .csproj files to change in a way that causes us issues - NuGet packages not found on our artifact server, or a new (or additional) version of some Microsoft.whatever.dll attempting to be used.

What I would like to do is somehow define a standard development environment for both our developers and our build server to use. Solutions like Docker immediately come to mind, and we have used this on our build server - but that's just running command line tools to accomplish the build, not running the entire Visual Studio IDE.

Is there an existing best practice for how to control/manage the issues I'm describing? I hope this question isn't closed as "asking for a library".

I think what I ideally want is something we can give to a new developer (or use if a hard drive crashes) where they can get a Visual Studio installation, along with the required tools and SDKs available, and be up and running very quick. In addition, I want to somehow "exclude" anything that isn't part of this setup - such as locally-installed libraries that are outside of the container.

Our application current targets dotnetcore 3.1 - yes, I know that's an unsupported version now.


Solution

  • You can look into using a global.json file. This file helps you specify what SDK version(s) you want to use. This file can be placed into any folder and would be used by the current and all subfolders. Any global.json file inside a subfolder would override it. You could have these files in each of your repositories.

    The quickest way to create a file would be using the dotnet CLI

    dotnet new globaljson
    

    You can read more on how to set the SDK here: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

    For nugets, you can look into setting up a NuGet config file. You can use the following dotnet CLI for creating one:

    dotnet new nugetconfig
    

    You can read more about it here: https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file