Xml and config transformation does not work on UWP
soroshsabz opened this issue · 4 comments
ITNOA
transformation in UWP project dose not work when Application try to run with f5 in appx directory. it is just work in default output directory such as Debug or Release
I add some question for this in Stackoverflow
And I add some question for this in Microsoft Q&A
After many working I found solution, AppX Packaging is coordinate from Microsoft.AppxPackage.Targets
that exists in Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage
and all important target for packaging and running (f5 in Visual Studio) exists here.
As you can see in this file, Microsoft create some blank target between important target in build and packaging pipeline, so you can use override these blank targets very cleanly to control procedure of building and packaging AppX, for example you can override blow targets
<!-- Override to specify actions to happen before generating project PRI file. -->
<Target Name="BeforeGenerateProjectPriFile" />
or
<!-- Override to specify actions to happen after generating project PRI file. -->
<Target Name="AfterGenerateProjectPriFile" />
or ...
So for adding custom files into packaging I override BeforeGenerateProjectPriFile
target and for adding file, I used PackagingOutputs
ItemGroup
for adding my file like below
<Target Name="BeforeGenerateProjectPriFile">
<ItemGroup>
<PackagingOutputs Include="$(MSBuildProjectDirectory)\$(OutputPath)$(AssemblyName).exe.config">
<OutputGroup>ContentFilesProjectOutputGroup</OutputGroup>
<TargetPath>$(AssemblyName).exe.config</TargetPath>
<ProjectName>$(ProjectName)</ProjectName>
</PackagingOutputs>
</ItemGroup>
</Target>
If you want this approach in practice, I used this technique in linphone-windows10
I want to make PR for adding this systemically in slow-cheetah, after merging my previous PR #261.
@adrianvmsft Please assign this issue to me
thanks