ITNOA
As you can see in Web Deployment Tool (MSDeploy) : Build Package including extra files or excluding specific files and Adding Custom Files to an MSDeploy Package msbuild desired target has property event that name is PipelineCopyAllFilesToOneFolderForMsdeployDependsOn
for handling copy desired files into process.
I need something similar for UWP, to add custom file copy to AppX
folder during packaging and f5 click
in Visual Studio in .csproj
file.
thanks
CodePudding user response:
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