diff --git a/msbuild-integration-demos/netcore3-single-file/README.md b/msbuild-integration-demos/netcore3-single-file/README.md index 573c36e..0aa9938 100644 --- a/msbuild-integration-demos/netcore3-single-file/README.md +++ b/msbuild-integration-demos/netcore3-single-file/README.md @@ -6,10 +6,12 @@ The feature provides a native way for dependencies embedding which is most benef # Running the example This directory contains an example of integrating SmartAssembly into .NET Core 3 single-file executable build: - [simplified-example](simplified-example) - .NET Core 3.1 console application protected by SmartAssembly, published as single-file. +- [multiple-runtimes](multiple-runtimes) - .NET Core 3.1 WPF application protected by SmartAssembly, published as single-file for **win-x64** and **win-x86** runtimes separately. Execute the `publish-and-run.bat` file from example above, to build, publish, and run the application protected by SmartAssembly. # More information Follow our documentation to see how to protect your single-file application by integrating SmartAssembly into your build process. -https://documentation.red-gate.com/sa7/building-your-assembly/using-smartassembly-with-single-file-executables-net-core-3 +- https://documentation.red-gate.com/sa8/building-your-assembly/using-smartassembly-with-single-file-executables-net-core-3 +- https://documentation.red-gate.com/sa8/building-your-assembly/using-smartassembly-with-single-file-executables-net-core-3/obfuscating-multiple-runtimes diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp.sln b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp.sln new file mode 100644 index 0000000..35d3778 --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30523.141 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "SampleApp\SampleApp.csproj", "{80E2B0A1-4A6B-49F6-99DA-70502DB030A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {80E2B0A1-4A6B-49F6-99DA-70502DB030A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80E2B0A1-4A6B-49F6-99DA-70502DB030A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80E2B0A1-4A6B-49F6-99DA-70502DB030A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80E2B0A1-4A6B-49F6-99DA-70502DB030A9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AB00FDA8-DBC8-4B7E-8B12-3E06E0E7CC50} + EndGlobalSection +EndGlobal diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/App.xaml b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/App.xaml new file mode 100644 index 0000000..6766fd7 --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/App.xaml.cs b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/App.xaml.cs new file mode 100644 index 0000000..ed7e778 --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace SampleApp +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/AssemblyInfo.cs b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/MainWindow.xaml b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/MainWindow.xaml new file mode 100644 index 0000000..d381cdb --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/MainWindow.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/MainWindow.xaml.cs b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/MainWindow.xaml.cs new file mode 100644 index 0000000..b5ee18f --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/MainWindow.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Reflection; +using System.Windows; + +namespace SampleApp +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + // You may want to move this to a separate ViewModel + public string ObfuscatedTypeName => typeof(SecretClass).FullName; + public string AssemblyBitness => typeof(MainWindow).Assembly.GetName().ProcessorArchitecture switch + { + ProcessorArchitecture.None => "Unknown", + ProcessorArchitecture.MSIL => "AnyCPU", + ProcessorArchitecture.X86 => "32-bit", + ProcessorArchitecture.IA64 => "IA-64", + ProcessorArchitecture.Amd64 => "64-bit", + ProcessorArchitecture.Arm => "ARM", + _ => throw new ArgumentOutOfRangeException() + }; + + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SampleApp.csproj b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SampleApp.csproj new file mode 100644 index 0000000..6ce7d31 --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SampleApp.csproj @@ -0,0 +1,23 @@ + + + + WinExe + netcoreapp3.1 + true + + + + + $(TargetPath) + $(IntermediateOutputPath)$(TargetName)$(TargetExt) + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SampleApp.saproj b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SampleApp.saproj new file mode 100644 index 0000000..6fe0ef7 --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SampleApp.saproj @@ -0,0 +1,34 @@ + + .\bin\Release\netcoreapp3.1\win-x64\SampleApp.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SecretClass.cs b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SecretClass.cs new file mode 100644 index 0000000..42fb3cd --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/SampleApp/SecretClass.cs @@ -0,0 +1,7 @@ +namespace SampleApp +{ + class SecretClass + { + // should be obfuscated + } +} diff --git a/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/build.bat b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/build.bat new file mode 100644 index 0000000..047164e --- /dev/null +++ b/msbuild-integration-demos/netcore3-single-file/multiple-runtimes/build.bat @@ -0,0 +1,8 @@ +dotnet publish .\SampleApp\SampleApp.csproj -r win-x64 -p:PublishSingleFile=true -c Release +dotnet publish .\SampleApp\SampleApp.csproj -r win-x86 -p:PublishSingleFile=true -c Release + +REM Execute 64-bit assembly +.\SampleApp\bin\Release\netcoreapp3.1\win-x64\publish\SampleApp.exe + +REM Execute 32-bit assembly +.\SampleApp\bin\Release\netcoreapp3.1\win-x86\publish\SampleApp.exe