我这里有一个wpf应用程序,它在安装应用程序后需要.net运行时。
这是。
<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>我创建一个构建并使用squirrel.windows创建一个安装文件。
我使用下面的powershell方法来实现这一点。
创建包:
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
}松鼠释放包裹
.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
}nuspec文件
<?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>现在,在我在一台新机器上安装这个应用程序之后,它说.net核心运行时没有安装,并且
未安装Microsoft.WindowsDesktop.App 3.1.0。
有人能提供一个有用的资源来说明我如何预先打包它并将其安装在应用程序旁边,这样用户就不必下载和安装.net核心运行时了吗?
发布于 2022-02-12 12:27:37
我迁移回.Net461,下面是我的nuspec文件:
<?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>https://stackoverflow.com/questions/68510218
复制相似问题