Comments
1 comment
-
To deploy a Winforms app developed using .NET 6 using the Visual Studio Installer (Setup & Deployment project), you have to trick the system via a workaround.1) You only need the following in your .vbproj file:<PropertyGroup>
<!-- I have a winforms app, so i set WPF=false, and form=true-->
<UseWindowsForms>true</UseWindowsForms>
<MyType>WindowsForms</MyType>
<UseWPF>false</UseWPF>
<!-- The line below is recommended when you first use VS 2022, since it will fetch a lot of resources that are used in the project-->
<Implicitusings>enable</Implicitusings>
<!-- I turn the next line off, since I don't need the assembly file rewritten-->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!-- The commands below are required for .NET 6 Winform apps, to run in Windows at least-->
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>
at the bottom of the .vbproj file, you need to overwrite the assembly:<PropertyGroup>
<SmartAssemblyOverwriteAssembly>true</SmartAssemblyOverwriteAssembly>
</PropertyGroup>2). Left-click on the Setup project, and then select File System Editor icon at the top of the properties ribbon of the Solution Explorer. Next, on the left panel, right-click on the Application Folder, then select Add-->Folder. Name the subfolder the same name as the VB project.3). Select Release in the Build Configuration, and right click on the VB Project in the right panel (the solution's projects), then Rebuild (do not build the Setup project in the Solution!)4). Navigate to obj\Release and notice the folder "net6.0-windows". Right click on this folder, select Copy, and then go to the new subfolder you made in Application Folder (left panel of File System Editor, of Setup project). Then on the right panel, in the whitespace, place your mouse over the whitespace, and right-click -- Paste.5). Next, double-click on the "net6.0-windows" folder, and look for the .exe file for your VB project. Right click on it then select Create Shortcut, and do this twice to make two shortcuts. Then click on the Desktop folder (left panel) and then in the whitespace on the right panel, right-click, then Paste the shortcut. Repeat this for the Program File list. Rename the shortcuts (as this is your app name that will be on the user's desktop after installation) and add the icon to each shortcut.
6). Right click on the Setup project in the solution, then select Rebuild. Then install your app by double-clicking on the .msi setup file that was generated. Your app will now have an icon on the desktop that can be double-clicked to run.(for those who are using SA to obfuscate, you can confirm the .dll is obfuscated by using the following steps).
7). You can confirm the output .dll for your project file in the "net6.0-windows" folder is obfuscated by using a trial version of .NET Reactor. After installation of .NET Reactor, right click on the .dll file in "net6.0-windows", then select Open with .NET Reactor, then click on the rightmost tab to view the assembly, and you can see that it's obfuscated.
8). After installing your app in Windows, you can confirm in C:\Program Files that the .dll is the same protected file using a trial version of ".NET Reactor". (I always check that what's installed in Windows is indeed the obfuscated assembly, since this is your last chance to confirm that what's distributed is protected).
Add comment
Please sign in to leave a comment.
<OutputType>WinExe</OutputType>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>