'Install Microsoft.WindowsDesktop.App along with wpf app during squirrel.windows install
I have a wpf app here which requires .net runtime after installation of the app.
Here is the App csproj.
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<Version>1.7.0</Version>
<AssemblyVersion>1.8.0</AssemblyVersion>
<FileVersion>1.8.0</FileVersion>
<Authors>Me</Authors>
<PackageIcon>AppIcon.JPG</PackageIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Images\SloVVo_Logo.JPG" />
<None Include="..\..\SloVVoNotes\Icon\AppIcon.JPG">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Config" Version="4.7.10" />
<PackageReference Include="NLog.Schema" Version="4.7.10" />
<PackageReference Include="System.Runtime.Caching" Version="5.0.0" />
<PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SloVVo.Logic\SloVVo.Logic.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\SloVVo_Logo.JPG">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\AddContent - Copy.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>AddContentWindow.xaml.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="bin\Debug\netcoreapp3.1\bin\" />
</ItemGroup>
</Project>
I create a build and use squirrel.windows to create a setup file.
I use the following powershell methods to acompish that.
Create package:
function Write-Package {
param(
[System.IO.DirectoryInfo] $BinDir,
[System.IO.FileInfo] $ExeFile,
[System.IO.FileInfo] $NuspecFile
)
$binDirPath = (Resolve-Path $BinDir).Path
$exeFilePath = (Resolve-Path $ExeFile).Path
$nuspecFilePath = (Resolve-Path $NuspecFile).Path
$version =$([System.Diagnostics.FileVersionInfo]::GetVersionInfo("$exeFilePath").FileVersion)
nuget pack $nuspecFilePath `
-Verbosity quiet `
-Version $version `
-OutputDirectory $binDirPath `
-BasePath $binDirPath
$nupkgFileName = Get-ChildItem -Path $binDirPath -Filter *.nupkg
$appName = $nupkgFileName.Name.Split('.')[0]
$nupkgFilePath = (Join-Path -Path "$binDirPath" -ChildPath "$appName.$version.nupkg")
return $nupkgFilePath
}
Squirrel Releasify the package
.Example
Write-Releases -SquirrelExe C:\tools\squirrel.exe -NupkgFile .\bin\Release\MyApp.1.0.0.nupkg
#>
function Write-Releases {
param(
[System.IO.FileInfo] $SquirrelExe,
[System.IO.FileInfo] $NupkgFile
)
$squirrelExePath = (Resolve-Path $SquirrelExe).Path
$nupkgFilePath = (Resolve-Path $NupkgFile).Path
$arguments= "--logLevel","Debug","--no-msi","--releasify",$nupkgFilePath
Start-Process -FilePath $SquirrelExe `
-ArgumentList $arguments `
-PassThru | Wait-Process
}
the nuspec file
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>MyApp</id>
<version>1.0.0</version>
<title>MyApp</title>
<authors>Me</authors>
<owners>Me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Application</description>
<dependencies>
<group targetFramework="netcoreapp3.1" />
<group targetFramework=".NETFramework4.5" />
</dependencies>
<frameworkReferences>
<group targetFramework="netcoreapp3.1" />
</frameworkReferences>
</metadata>
<files>
<file src="*\*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
</files>
</package>
Now, after I install the app on a new machine it says that .net core runtime is not installed and
Microsoft.WindowsDesktop.App 3.1.0 is not installed.
Could someone provide a useful resource as to how I can prepackage that and it's installed alongside the app so that the user does not have to download and install the .net core runtime?
Solution 1:[1]
I migrated back to .Net461 and the below is my nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>SloVVo</id>
<version>2.0.0</version>
<title>SloVVo</title>
<authors>Me</authors>
<owners>Me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Application</description>
<dependencies>
<group targetFramework=".NETFramework4.6.1"/>
</dependencies>
</metadata>
<files>
<file src="**\*.*" target="lib\net461" exclude="*.pdb;*.nupkg;*.vshost.*"/>
</files>
</package>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Artexias |
