How to handle web service and source control

I have a " class library " in my solution that is being used by my " WebService ". This web service is used by site clients. ( Now I have 2 projects under my solution )

There have been some improvements to the class library lately. I would like to implement Versioning in this library (not really sure how to do this.).

Let's say my current " Class Library v1 " needs to remain active because some of our clients who consume " Web Service " still need " Class Library v1 ". But for a few new clients, my " Web Service " needs to implement the Class Library v2 logic .

I started to duplicate my " Class Library v1 " and create a new project in my " Class Library v2 " solution and process it in my " web service " based on the request source. ( Now I have 3 projects under my solution )

For some reason, I feel like this is a very amateurish way of implementing it. Can anyone help me to make the correct path for the version libraries and call them accordingly.

+3


source to share


1 answer


This is usually implemented using version control branches.

  • There is a master branch that represents the most up-to-date code (and a branch that evolves regardless of product versions or milestones).

  • If you want to release a new version or version, the first step is to tag the version control with a version tag. For example: "My product is 2.2".

  • In addition, if the entire product version or revision will be supported in parallel with newer versions, you need to create a version / revision branch so that specific fixes, fixes, or features will be implemented there without affecting newer or older versions. If you want to split a feature into different branches, you need to merge the whole set. The main problem is that sometimes the codebase in older versions does not support merging, but you will need to develop a fix again for a specific version ...

  • Sub, sub-sub, sub-sub-branches can happen. For example, you might have a 2.x branch and a minor branch for 2.1.x, 2.2.x ... It all depends on how you handle product versions and releases.

  • Each branch is a different Visual Studio solution. You shouldn't mix satellite libraries in the same solution. Manage them yourself in your own solution with specific versions of the code files.

At the end of the day, you have all the branches of code in separate version control repositories, and you develop each version separately, then you merge the changes (or implement the change for a specific version).

Now you need to select a source control provider. You have many options:

Benchmarking vendor comparison is outside the scope of this Q&A, and it is very opinion-driven and it will not be in line with StackOverflow conventions, but it's up to you to decide some of them or even get to know others!

About the web service

In terms of serving your web service providing multiple versions to your consumers, you might need to think about a URI scheme where the base URI contains the web service version:



  • /api/v1/resourceA

  • /api/v2/resourceA

  • /api/v2.2/resourceA

  • ...

Update based on some OP comment

[...] I'm more interested in knowing the last part of your answer where you gave examples of URLs for the web services API. let's say i support different endings like v1, v2 and v2 for all clients, now my messages when request is sent from url v1 and url V2, i have to call my single class library or two different class libraries.

As I pointed out in this answer above, you will need to maintain each version of your solution separately, and you will need to deploy each version as a different IIS application.

You may need to learn a little about WebDeploy to deploy your solutions with less effort.

If you go with one solution and v1, v2, v2, v3 class libraries, you will face a lot of problems in the future, because you change the code to work in the latest version, and in the previous one.

Imagine your API v1 works with .NET 3.5, v2 works with .NET 4.x and v3 .NET vNext (5?). You will not be able to build / compile a web services solution in a single application that can run more than .NET CLR in the same IIS application (* this is one possible problem, we can continue next; P!)

+2


source







All Articles