There are multiple conditions that need to be meet in order to generate transforms correctly
Inside .csproj make sure you have all of the following:
<Project> ...
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.targets" />
<Target Name="SetTransformAppConfigDestination" BeforeTargets="PrepareForBuild" Condition="exists('Web.$(Configuration).config')">
<PropertyGroup>
<!-- Force build process to use the transformed configuration file from now on. -->
<AppConfig>$(IntermediateOutputPath)$(TargetFileName).config</AppConfig>
</PropertyGroup>
<Message Text="AppConfig transformation destination: = $(AppConfig)" />
</Target>
<Target Name="TransformAppConfig" AfterTargets="PrepareForBuild" Condition="exists('Web.$(Configuration).config')">
<TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="$(AppConfig)" />
</Target>
</Project>
Update your item group in .csproj file as well .
<ItemGroup> ...
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</Content>
<Content Include="Views\Web.config" />
<Content Include="Views\Home\Index.cshtml" />
</ItemGroup>
This will result in your config file to be nested in explorer view

Then make sure you have your path set correctly in properties -> build

Then add to your web.release.config tags for each node to be transformed
- xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
- xdt:Transform="Replace"
to look like this:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="Replace">
<add key="VariableToBeTransformed" value="ValueToInsert"/>
</appSettings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Also make sure your Solution configuration matches Debug/Release as intended

Hope this helps everyone, you can do the same for app.config