8 configuration-files .net-core
当我在 Visual Studio 中构建AppinRelease模式时,它会在 Release 文件夹中生成这些文件:
App.exe
App.dll
App.runtimeconfig.json
App.pdb
App.deps.json
App.runtimeconfig.dev.json
Run Code Online (Sandbox Code Playgroud)
如果我移动前 3 个文件位置并双击App.exe它开始。如果我删除App.runtimeconfig.json它不会启动!
我只想保持App.exe和App.dll我的文件夹中,我有什么做的摆脱的那个App.runtimeconfig.json?
编辑
以下是内容App.runtimeconfig.json:
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"framework": {
"name": "Microsoft.WindowsDesktop.App",
"version": "3.0.0"
}
}
}
Run Code Online (Sandbox Code Playgroud)
编辑
这是我现在在我的App.csproj文件中的内容PropertyGroup:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<UseWPF>true</UseWPF>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
现在我在Error ListVisual Studio 中得到了这个:
Error NETSDK1047 Assets file 'C:\Users\Emon\source\repos\SocketTest\App\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.0/win-x64'. Ensure that restore has run and that you have included 'netcoreapp3.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers. App C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234
Run Code Online (Sandbox Code Playgroud)
当我右键单击“项目”时,我看到:“构建”、“清理”、“重建”等,但没有还原!
编辑
我首先删除了bin和obj文件夹并重新排序了<PropertyGroup>将 放在<RuntimeIdentifier>下方<TargetFramework>,现在它可以工作了!
如您所见,App.runtimeconfig.json包含运行时信息和使用的.NET Core版本,您不能简单地删除它。Self-contained但是您可以在发布应用程序时通过选择部署模式切换到自包含部署
.NET Core 引入了修剪结果可执行文件以减小大小的功能。基本上,您的项目文件中需要以下属性
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
Run Code Online (Sandbox Code Playgroud)
有一篇关于单个可执行文件的非常好的文章
| 归档时间: |
|
| 查看次数: |
9572 次 |
| 最近记录: |