Recently I wanted to (finally) automate builds & submissions for all my UWP apps. Deploying a UWP app manually is a long process since it always creates a full .NET native build. This is only required for the certification kit and the store only uses the MSIL package. Before we dive into automating builds for UWP apps, let’s stay focused on debugging Cake extensions first.
The Cake extension I was working on is Cake.WindowsAppStore. It can be used to automatically create submissions for Windows Store apps. Debugging Cake add-ins is a bit of a thing, and there are several ways to do it. In this post I’ll describe what I think is the easiest way to debug Cake add-ins.
Step 1: Copy extension to the add-in directory in the cake script
The first thing we must do is to make sure that Cake uses the latest debug build of the add-in we want to debug. We can do this by creating this post-build step for the add-in project in Visual Studio:
xcopy /s /f /y “C:\Source\Cake.WindowsAppStore\src\Cake.WindowsAppStore\bin\Debug\net45\*” “C:\Source\MyApp\tools\Addins\Cake.WindowsAppStore\lib\net45\”
Note 1: this is stored in the csproj file and will be used for all users
Note 2: I would normally have used the build macros, but they don’t work (yet)
Step 2: Set the debug options to run Cake directly
In Visual Studio, go to the Project Properties and select the Debug tab:
1. Set Launch to Executable
2. Set Executable to C:\Source\MyProject\tools\Cake\Cake.exe
3. Set Application Arguments to build.cake -target=Deploy (where target is obviously the Cake target you want to run)
4. Set Working Directory to the project directory you want to run the Cake script against, e.g. C:\Source\MyProject\
Note that this is a user-specific setting so will only work on your machine
Below is a screenshot of the final result:
Step 3: Enjoy your debugging experience