I have a solution with several ASP.NET 4.8 web projects, some of them are "master" projects that get deployed, the remaining projects are modules used by the "master" projects.
Let's assume the solution looks like this:
Each of the master projects has its own pubxml profile for publishing.
The master projects were published using Visual Studio's "Rightclick -> Publish" functionality which uses those profiles.
The master projects have the following setting set so that subdirectories get deployed too:
I'm tasked to automate this process using cli tools to be able to publish the projects in Azure Pipelines but for now I would like to get it working locally first.
To accomplish this I first tried the following command:
msbuild.exe Solution.sln /t:"Project1\Master1" /p:DeployOnBuild=true /p:PublishProfile=master1publish /p:VisualStudioVersion=17.0
When I execute this command, I get several error complaining that the "master1publish" profile could not be found for all the module projects of Master1.
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\Web\Microsoft.Web.Publishing.targets(4438,5): error : The value for PublishProfile is set to 'master1publish', expected to find the file at 'D:\Solution\Project1\Modules\Module1\Properties\PublishProfiles\master1publish.pubxml' but it could not be found. [D:\Solution\Project1\Master1.csproj]
I searched for this and found out that properties passed to msbuild.exe are global properties and are applied to every project that gets built, so I guess that's why I get the errors.
I also tried to pass the absolute path to the publish profile but it's the same story, msbuild tries to publish each individual sub project.
Next I found a possible solution on Sayed Ibrahim Hashimi - MSBuild, Web Deploy (MSDeploy), ASP.NET - How to publish one web project from a solution (sedodream.com)
A colleague of mine tried this but it didn't really work for some reason, the provided solution isn't really feasible either as we have a lot of modules to change for this.
Visual Studio is able to deploy those projects without applying the provided solution so I guess it should work without it.
A lot of tutorials on how to deploy web projects pass the csproj file to msbuild directly like
msbuild.exe Project.csproj ... instead of using the sln file.
Unfortunately we cannot do this as the projects need a solution in order to be buildable in our case.
I don't really know what to do next, it seems that every single tutorial on the internet cannot be applied to the solution I have to work with.
Visual Studio is able to publish those projects using only the pubxml files so my expectation is that there must be a way to replicate this behaviour using msbuild and/or msdeploy.
I really hope that anyone here can suggest me anything to get further with this task.