[当我在Visual Studio中以App
模式构建Release
时,它将在Release文件夹中生成这些文件:
App.exe
App.dll
App.runtimeconfig.json
App.pdb
App.deps.json
App.runtimeconfig.dev.json
如果我从硬盘上的其他位置中取出前三个文件,然后双击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" } } }
编辑
这是我现在在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>
现在我在Visual Studio的
Error List
中得到了这个:
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
当我右键单击Project时,我看到:Build,Clean,Rebuild等,没有还原!
编辑
我首先删除了bin
和obj
文件夹,并对<PropertyGroup>
进行了重新排序,将<RuntimeIdentifier>
放在<TargetFramework>
下方,现在可以使用了!在具有一些nuget包引用,使用INotifyPropertyChanged,ICommand,IDataErrorInfo等的另一个Socket Client Apllication中,self-contained app
的同一过程会生成很多文件!在名为win-x64
的输出文件夹中,我有296个项目,包括该Socket App的13个锻件(cs,de,es,fr,it等),它仍然包含这3个.json
,一个.md
还有一些.pdb
!文件夹的大小为150MB!
现在我只能删除那些.pdb
,2 .json
和那13个语言文件夹。如果删除Client.deps.json
或.md
,则应用无法启动!
[当我在Visual Studio中以发布模式构建应用程序时,它将在Release文件夹中生成以下文件:App.exe App.dll App.runtimeconfig.json App.pdb App.deps.json App.runtimeconfig.dev.json ...
如您所见,App.runtimeconfig.json
包含运行时信息和使用的.NET Core版本,您不能简单地将其删除。但是,通过在发布应用程序时选择Self-contained
部署模式,可以切换到独立部署。
。NET Core引入了修剪结果可执行文件以减小大小的功能。基本上,您的项目文件中需要以下属性