How to create common publish profile in Visual Studio 2019

Viewed 399

I have a solution with multiple projects. The PublishSettings.targets file is in the root.

enter image description here

PublishSettings.targets

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <publishUrl>D:\inetpub\wwwroot\sctest5</publishUrl>
    <ExcludeFilesFromDeployment>
      bin\roslyn\*;bin\Coveo.*.dll;bin\Newtonsoft.*.dll\Sitecore.WFFM.*;bin\*.pdb;*.config;bin\System.*.dll;bin\*.config;
      bin\Microsoft.*.dll;bin\Sitecore.Kernel.dll;bin\Sitecore.Mvc.dll;bin\DynamicPlaceholders.*.dll;bin\Newtonsoft.json.dll;bin\DynamicPlaceholders.dll;
    </ExcludeFilesFromDeployment>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <DeleteExistingFiles>False</DeleteExistingFiles>
    <ExcludeFoldersFromDeployment>sourcefiles;raw-images;bin\App_Config\;bin\App_Config\Include\Social;</ExcludeFoldersFromDeployment>
  </PropertyGroup>
</Project>

Now, in each project I would like to have a publish profile that would read from the PublishSettings.targets file, like this:

Local.pubxml

<?xml version="1.0" encoding="utf-8"?>

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="..\..\..\..\..\..\..\PublishSettings.targets"/>
</Project>

So that, if the target publish folder needs to be changed, it can be done only at one place i.e PublishSettings.targets.

But, when I create this Local.pubxml in one of the projects and try to publish, seems it is not reading the global file.

enter image description here

I tried changing this part "..\..\..\..\..\..\..\ by adding/removing levels, but it still doesn't work.

I was able to follow the same for previous projects using Visual Studio 2017.

How can I achieve this or is there a simpler alternative.

0 Answers
Related