I found the answer here:
How to auto publish a project just after building?
When building or rebuilding a solution, I want to automatically publish all the publishable project within my solution.
Developer technologies | .NET | Other
2 answers
Sort by: Most helpful
-
-
Anonymous
2024-08-09T09:44:40.4+00:00 Hi @Tony Enrique Orozco Suarez , Welcome to Microsoft Q&A,
Since Q&A users cannot mark their own answers, I will reorganize and post your answer.
You can't trigger the web publish via as that's automatically disabled when building from Visual Studio.DeployOnBuild
You can, however, trigger the process as part of the same MSBuild invocation via some MSBuild trickery:
<!-- In Directory.Build.props or the csproj (before the web targets import) --> <PropertyGroup> <PublishProfile>Local</PublishProfile> </PropertyGroup>
And also:
<!-- After the above, or in ProjectName.wpp.targets --> <PropertyGroup> <AutoPublish Condition="'$(AutoPublish)' == '' and '$(Configuration)' == 'Debug' and '$(BuildingInsideVisualStudio)' == 'true' and '$(PublishProfile)' != ''">true</AutoPublish> <AutoPublishDependsOn Condition="'$(AutoPublish)' == 'true'"> $(AutoPublishDependsOn); WebPublish </AutoPublishDependsOn> </PropertyGroup> <Target Name="AutoPublish" AfterTargets="Build" DependsOnTargets="$(AutoPublishDependsOn)"> </Target>
If you're finding that your publish project isn't being built when you make content changes, add the following:
<!-- csproj ONLY, won't work elsewhere --> <PropertyGroup> <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck> </PropertyGroup>
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.