#DevOps – WebSites, Azure and Error: Multiple types were found that match the controller named ‘messages’.

Hi!

I’ll leave it written down in a post so I will not forget later. Let’s start with the context

  • We work with a web App. For example, a Microsoft Bot App with Visual Studio
  • The deployment of it is done to Azure as part of an automated process (DevOps rules!)
  • Everything works perfectly

Until in a moment you find that your Web App does not work anymore. And when you try to navigate one of the controllers, a message like the following may appear

Multiple types were found that match the controller named ‘messages’. This can happen if the route that services this request (‘api/{controller}/{id}’) found multiple controllers defined with the same name but differing namespaces …

There are several reasons why this usually happens. However, one of the most popular is that you have renamed or changed some namespaces and new Dlls have been generated as part of the solution. The problem is that, by default, and as a mechanism to save processing time, the deployments only copy the assemblies that have been modified to the destination location. In this case, to an IIS folder, so a mix of files is in the bin folder.

Before continuing I have to take up the words of the great  Damian Brady (@damovisa):

Friends don’t let friends right-click publish

The first time you have seen an option that allows you to clean the destination directory and then copy the compilation directory is in the Publish option of a website in Visual Studio 2017

I1

Well, if you have configured the publication of your website as part of a Build – Releases process, it is in this last section that you will find the option [Remove additional files at destination], which will eliminate the unnecessary Assemblies of your solution.

I2

Happy Coding!

Greetings @ Toronto

El Bruno

Advertisements

#DevOps – WebSites, Azure y multiples controllers. Error: Multiple types were found that match the controller named ‘messages’.

Buenas!

Lo voy a dejar apuntado en un post para que luego no me olvide. Comencemos por el contexto

  • Trabajamos con una App web. Por ejemplo, una Microsoft Bot App con Visual Studio
  • El despliegue de la misma se realiza a Azure como parte de un proceso automatizado (DevOps rules!)
  • Todo funciona perfectamente

Hasta que en un momento te encuentras que tu Web App no funciona más. Y cuando intentas navegar uno de los controllers, puede aparecer un mensaje como el siguiente

Multiple types were found that match the controller named ‘messages’. This can happen if the route that services this request (‘api/{controller}/{id}’) found multiple controllers defined with the same name but differing namespaces …

Hay varios motivos por los que suele suceder esto. Sin embargo uno de los mas populares es que has renombrado o cambiado algunos namespaces y se han generado nuevas Dlls como parte de la solución. El problema está en que, por defecto, y como mecanismo para ahorrar trabajo, los despliegues solo copian los ensamblados que se han modificado a la ubicación de destino. En este caso, a un folder de IIS.

Antes de seguir tengo que retomar las palabras del gran Damian Brady (@damovisa):

Friends don’t let friends right-click publish

La 1ra vez que has visto una opción que te permite limpiar el directorio de destino y luego copiar el directorio de compilación es en la opción Publish de un website en Visual Studio 2017

I1

Pues bien, si has configurado la publicación de tu website como parte de un proceso de Build – Releases, es en esta última sección donde encontraras la opción [Remove additional files at destination], que eliminara los Assemblies innecesarios de tu solución

I2

Happy Coding!

Saludos @ Burlington

El Bruno