0

I've used the Setup Project in Visual Studio for Console apps with no problems, however, until now, I've always ran any WPF apps I've created in Visual Studio. This is my first attempt at publishing one. I feel this would be pretty simple if I only knew what to do with my subfolders. I have many images that I use for buttons, a PNG for a logo, and two PowerShell scripts.

images

other resources

Do I need to select more than just the Primary output?

setup wizard

Here is the usage of the data for reference:

The PowerShell Scripts (just showing relevant code):

 private static string checkAppsScript = File.ReadAllText(@"scripts\checkApps.ps1");
 private static string removeAllScript = File.ReadAllText(@"scripts\removeall.ps1");

 PowerShell removePS = PowerShell.Create();
 removePS.AddScript(removeAllScript);

 PowerShell ps = PowerShell.Create();
 ps.AddScript(checkAppsScript);

The images from the data folder from my XAML (There are 18. Just showing 1):

<StackPanel Grid.Row="0" Grid.Column="0">
    <Button Name="bingweatherBtn" Margin="10" Style="{StaticResource ImageButtonStyle}" Click="ImageBtn_Click">
        <Button.BitmapEffect>
            <DropShadowBitmapEffect Color="Black" Direction="320" Opacity="0.8"/>
        </Button.BitmapEffect>
            <Border BorderBrush="Black" BorderThickness="2">
                <Image Source="data\weather_icon80x80.jpg"></Image>
            </Border>
        </Button>
        <Label Content="Bing Weather" FontSize="14" FontWeight="SemiBold" Padding="0" HorizontalAlignment="Center"></Label>
</StackPanel>

Any tutorials I've managed to find all show simple Console apps or simple WPF apps without additional folders. After creating my .msi file, the executable does nothing. It shows a busy animation for about a second and quits.

What am I doing wrong here? Why does my app only run in Visual Studio?

Note: Everything in the data and Resources folder is set as Content for the 'Build Action', and the PS scripts are set as Embedded Resource. I don't know if this is correct. Target platform is set to x64.

DevOpsSauce
  • 1,319
  • 1
  • 20
  • 52

2 Answers2

0

I am not too familiar with the topic, however here are a few suggestions:

Using Visual Studio:

  1. Run project interactively (Debug => Start Debugging).
  2. Go to Debug => Windows => Modules.
  3. You should see a list of everything that was loaded for the application to run.

I am not sure, frankly, if this gives you all types of dependencies. There can be many different types as explained here in the Dependency Walker help file.

Dependency Walker is an old Windows SDK tool. It is very outdated by now - over 10 years since the last update I think.

Make sure you deploy the files that are loaded for your solution in Visual Studio (I suppose you should run your release build) - and / or identify the correct runtime to deploy the runtime component.

Personally, I would install your existing MSI file, and then put one file at a time in place on disk in the release location until your application launches and runs. Then you proceed to test the application features to identify any further dependencies. Visit all dialogs and use all functions.


Dependencies.exe:

Maybe you can also try this new, open source rewrite of Dependency Walker (that old SDK tool mentioned above) partially done in C#: "Dependencies.exe". This tool is quite unfinished and doesn't feature all functionality from Dependency Walker (I can't see any profiling features for exe files), but it has support for API-sets and WinSxS dependencies - or side-by-side Win32 assemblies (which is missing from Dependency Walker). I haven't tested it enough to really recommend it - but it is open source and hence inspectable. It seems you need to build it yourself from the source (for now).

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • I can see all my dependencies in the Application Folder when I'm creating the installer. It's the images and the two scripts I don't know how to include. This is so much easier with Android Studio. I'm completely new to this. – DevOpsSauce Dec 20 '17 at 16:32
  • I suppose you can also try [ProcMon64.exe](https://live.sysinternals.com/procexp64.exe) as indicated in [**this answer**](https://stackoverflow.com/a/47792474/129130). – Stein Åsmul Dec 20 '17 at 17:08
  • Sorry, I pointed to the wrong executable: I suppose you can also try [ProcMon.exe](https://live.sysinternals.com/Procmon.exe) as indicated in [**this answer**](https://stackoverflow.com/a/47792474/129130). – Stein Åsmul Dec 20 '17 at 17:22
0

I removed the scripts and hard coded them into the MainWindow.xaml.cs file like so:

private static string checkAppsScript = @"$appList = @('*BingNews*','*BingWeather*','*OneNote*','*WindowsAlarms*', 
                                                           '*Recorder*', '*Maps*','*Camera*', '*Microsoft.People*',
                                                           '*xboxapp*', 'ZuneMusic*','*Messaging*', '*Builder*', 
                                                           '*BubbleWitch*', '*Minecraft*', '*Spotify*',
                                                           '*Empires*', '*StickyNotes*', '*Skype*', '*SolitaireCollection*')


                                            ForEach($app in $appList)
                                            {
                                              Get-AppxPackage | Select Name | Where-Object {$_.Name -like $app}
                                            }";

I removed the images and re-added them using "Add Existing Item." I had originally used "Add Item." I placed all images in a res folder (I had two folders, which was pointless). The executable now works.

DevOpsSauce
  • 1,319
  • 1
  • 20
  • 52