Skip to content

Commit

Permalink
Build as single exe and target win7-x64/x86
Browse files Browse the repository at this point in the history
Drop nuget package for now
  • Loading branch information
tjmoore committed Jan 15, 2020
1 parent 63b0e09 commit e04d4f4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 59 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
with:
dotnet-version: 3.1.100

- name: Build with dotnet
run: dotnet build --configuration Release
- name: Build x64
run: dotnet publish -c Release -r win7-x64

- name: Build x86
run: dotnet publish -c Release -r win7-x86


35 changes: 0 additions & 35 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class App : Application

private void Application_Startup(object sender, StartupEventArgs e)
{
var rootCommand = new RootCommand(description: "Reports .NET runtime version information and triggers a prompt to install .NET Core runtime if applicable")
var rootCommand = new RootCommand(description: "Reports .NET runtime version information and/or triggers a prompt to install .NET Core runtime if applicable")
{
new Option(new[] { "--no-window" }, "Don't display window, write version information to console"),
new Option(new[] { "--silent" }, "Don't display window or write to console. Useful to only trigger .NET Core install if necessary")
Expand Down
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,11 @@

Reports .NET runtime version information and/or triggers a prompt to install .NET Core runtime if applicable


This relies on .NET Core 3+ built-in support for prompting download and install of .NET Core runtime if not installed when running an executable. This only occurs with Windows GUI Executables.

The idea is this is a simple executable that can be run during an installer, letting the .NET Core Windows executable bootstrap handle runtime version checking, download and installation. This is useful where the actual .NET Core application being installed is a console or service application which won't generate a prompt and in the case of a service cannot prompt the user without desktop interactivity.

Additionally, this application can produce a window showing the runtime and target information or send that information to a console.

An alternative is to go checking install locations and/or registry as described here:

https://github.com/dotnet/designs/blob/master/accepted/install-locations.md

However this is somewhat complicated, especially if you want to depend on a compatible install being present, e.g. same version or newer minor & patch version, so that you can pick up latest fixes. This process is built into .NET Core 3 Windows GUI executables anyway so it would seem to make sense to use that functionality.

Note, this depends on Framework Dependent Executable (FDE) mode of deployment (which is also the default for FDD now in .NET Core 3). It's not relevant to Self Contained Deploment (SCD) as the published application will contain all the dependent runtime and is fixed to the specified target runtime version and platform.

This primarily is aimed at .NET Core. It might be possible to target .NET Framework and it may report the versions, but even if that works, it likely won't prompt for install.

The code provided here could act as an example to integrate into other applications, although the actual prompt for install functionality only really requires targetting WinExe output type.

## Usage

```
dotnet-version-check:
Reports .NET runtime version information and triggers a prompt to install runtime if applicable
Reports .NET runtime version information and/or triggers a prompt to install runtime if applicable
Usage:
dotnet-version-check [options]
Expand All @@ -37,3 +18,17 @@ Options:
--silent Don't display window or write to console. Useful to only trigger .NET Core install if necessary
--version Display version information
```

This relies on .NET Core 3+ built-in support for prompting download and install of .NET Core runtime if not installed when running an executable. This only occurs with Windows GUI Executables.

This idea behind this is primarily for use when installing console or service applications that cannot self-prompt for install of the runtime. The solution here is by creating a WinExe executable targetting .NET Core 3 and running that during install, it should prompt for the missing runtime. This is as an alternative to scripting an installer to detect a compatible runtime globally installed which can be somewhat complex and the framework has built in support for this anyway.

The executabe need do nothing other than start and shut down, but it does have to be a WinExe target.

In this example it does a little more by providing a window showing the installed framework and/or reporting to console, but with a 'silent' option for use in an installer so it either does nothing or the user receives a prompt to install the runtime.

Note, this depends on Framework Dependent Executable (FDE) mode of deployment (which is also the default for FDD now in .NET Core 3). It's not relevant to Self Contained Deploment (SCD) as the published application will contain all the dependent runtime and is fixed to the specified target runtime version and platform.

This primarily is aimed at .NET Core. It might be possible to target .NET Framework and it may report the versions, but even if that works, it likely won't prompt for install.


7 changes: 7 additions & 0 deletions dotnet-version-check.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<!-- Needs to be WinExe to trigger install prompt for .NET Core. This does prevent console output though so have to work around that -->
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>

<!-- Target win7 x86/x64 but not self contained so is FDE, yet package as single file and compile ready-to-run for small executable -->
<RuntimeIdentifiers>win7-x64;win7-x86</RuntimeIdentifiers>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>

<RootNamespace>DotNetVersionCheck</RootNamespace>
<UseWPF>true</UseWPF>
<PackageId>DotNetVersionCheck</PackageId>
Expand Down

0 comments on commit e04d4f4

Please sign in to comment.