I am working on custom branding using Visual Studio for SharePoint 2016 On-prem environment.
I got 2 masterpages (HomeResponsive16.master and Responsive16.master) and few page layouts. By default, Responsive16.master is set on the site. I want couple of page layouts (for instance Home-2Col.aspx) to use the other masterpage (i.e. HomeResponsive16.master) and not the default one.
My Home-2Col.aspx page layout's Page directive looks like this:
<%@ Page language="C#" MasterPageFile="HomeResponsive16.master" CodeBehind="Home-2Col.aspx.cs" Inherits="ResponsiveToolkit._16.PageLayouts.Home_2Col, $SharePoint.Project.AssemblyFullName$" %>
When I create a page (defaultnew.aspx) using the Home-2Col page layout, it still loads using the default master page rather than the one I set in the Page directive.
I also tried adding the code-behind for the page layout and setting the master page on the PreInit event but even that didn't work. I also confirmed that the SafeControl entry is present in the web.config for the code-behind.
Below is how my VS Solution looks like.