{"id":320098,"date":"2021-03-23T09:00:47","date_gmt":"2021-03-23T09:00:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=320098"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=320098","title":{"rendered":"\u0423\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e .NET 5.0 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h2>Target Framework Moniker<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f. \u0412 .NET 5.0 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Windows Forms \u0438\u043b\u0438 WPF \u043d\u0430\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c net5.0:<\/p>\n<pre><code class=\"xml\">&lt;PropertyGroup&gt;   &lt;TargetFramework&gt;net5.0&lt;\/TargetFramework&gt;   &lt;UseWindowsForms&gt;true&lt;\/UseWindowsForms&gt; &lt;\/PropertyGroup&gt;<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Windows Forms \u0438\u043b\u0438 WPF \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443<\/p>\n<pre><code>C:\\Program Files\\dotnet\\sdk\\5.0.201\\Sdks\\Microsoft.NET.Sdk\\targets\\Microsoft.NET.Sdk.DefaultItems.targets(369,5): error NETSDK1136: The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so.<\/code><\/pre>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u0430\u043a \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/frameworks\" rel=\"noopener noreferrer nofollow\">Target Framework Moniker<\/a><\/p>\n<pre><code class=\"xml\">&lt;PropertyGroup&gt;   &lt;TargetFramework&gt;net5.0-windows&lt;\/TargetFramework&gt;   &lt;UseWindowsForms&gt;true&lt;\/UseWindowsForms&gt; &lt;\/PropertyGroup&gt;<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h2>\n<p>\u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u0438\u0437 Microsoft.NET.Sdk\\targets.<br \/>\u0414\u0430\u043b\u0435\u0435 \u0432 dotnet\\sdk\\5.0\\Sdks\\Microsoft.NET.Sdk.WindowsDesktop\\targets\\Microsoft.NET.Sdk.WindowsDesktop.props \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043a\u043e\u0434:<\/p>\n<pre><code class=\"xml\">    &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App\" IsImplicitlyDefined=\"true\"                         Condition=\"('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' == 'true')\"\/&gt;      &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App.WPF\" IsImplicitlyDefined=\"true\"                         Condition=\"('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' != 'true')\"\/&gt;      &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App.WindowsForms\" IsImplicitlyDefined=\"true\"                         Condition=\"('$(UseWPF)' != 'true') And ('$(UseWindowsForms)' == 'true')\"\/&gt;<\/code><\/pre>\n<h2>\u0413\u0434\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e FrameworkReference \u044d\u0442\u043e \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c: <a href=\"https:\/\/github.com\/dotnet\/designs\/blob\/main\/accepted\/2019\/targeting-packs-and-runtime-packs.md\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0434\u0438\u0437\u0430\u0439\u043d\u0430 .NET<\/a> , <a href=\"https:\/\/github.com\/NuGet\/Home\/wiki\/%5BSpec%5D-FrameworkReference-in-NuGet\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f NuGet<\/a><\/p>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u0434\u0435-\u0442\u043e \u0441\u0431\u043e\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0438\u043f \u0438\u0437 Windows Forms \u0438\u043b\u0438 \u0438\u0437 WPF \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 &#8216;net5.0-windows&#8217;.<\/p>\n<p>\u042d\u0442\u043e \u0433\u0440\u043e\u0437\u0438\u0442 \u043d\u0430\u043c \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0439 \u0445\u043b\u0430\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Windows Forms \u0438\u043b\u0438 WPF \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0442, \u0430 \u0435\u0441\u043b\u0438 \u043c\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 60\u041c\u0411 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/p>\n<pre><code class=\"cs\">using System.Windows.Forms;  namespace Library {     public class Demo     {         void ShowForm()         {             var f = new Form();             f.Show();         }     } } <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<pre><code class=\"cs\">using System;  class Program {     public static void Main()     {         Console.WriteLine(\"Hello World!\");     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 Library.Demo.<\/p>\n<p>\u0421\u043e\u0431\u0435\u0440\u0451\u043c \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dotnet publish:<\/p>\n<pre><code class=\"powershell\">dotnet publish ConsoleApp.csproj --self-contained -c Release -r win-x64 \/p:PublishSingleFile=true \/p:PublishTrimmed=true \/p:IncludeAllContentForSelfExtract=true<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 81,8\u041c\u0411 !<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f IncludeAllContentForSelfExtract \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 %TEMP%\\.net \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0437 \u0447\u0435\u0433\u043e \u043e\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442.<\/p>\n<figure class=\"float bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/599\/57d\/e7c\/59957de7cbfe0aaa9e90e6b2233fdb31.png\" width=\"531\" height=\"914\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0436\u0435 \u0442\u0430\u043a ?<br \/>\u041c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Library.Demo, \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 PublishTrimmed, \u0430 Windows Forms \u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u0451\u043b.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c dotnet publish \u043f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u0435\u043c\u0443 !<\/p>\n<h3>\u0428\u0430\u0433 1<\/h3>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"xml\">&lt;Project Sdk=\"Microsoft.NET.Sdk\"&gt;    &lt;PropertyGroup&gt;     &lt;TargetFramework&gt;net5.0&lt;\/TargetFramework&gt;     &lt;!-- \u0423\u043a\u0430\u0436\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u044f\u0432\u043d\u043e --&gt;     &lt;DisableImplicitFrameworkReferences&gt;true&lt;\/DisableImplicitFrameworkReferences&gt;   &lt;\/PropertyGroup&gt;     &lt;ItemGroup&gt;     &lt;!-- .NET Runtime --&gt;     &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0432\u0430\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 PrivateAssets=\"all\" \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 --&gt;     &lt;FrameworkReference Include=\"Microsoft.NETCore.App\" \/&gt;          &lt;!-- Windows Desktop --&gt;     &lt;!-- PrivateAssets=\"all\" - \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0435 \u0438\u0434\u0451\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 --&gt;     &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App\" PrivateAssets=\"all\"  \/&gt;          &lt;!-- \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e:       Microsoft.WindowsDesktop.App.WPF       Microsoft.WindowsDesktop.App.WindowsForms --&gt;   &lt;\/ItemGroup&gt;  &lt;\/Project&gt;<\/code><\/pre>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043b\u044f <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/project-sdk\/msbuild-props#disableimplicitframeworkreferences\" rel=\"noopener noreferrer nofollow\">DisableImplicitFrameworkReference<\/a><\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/consume-packages\/package-references-in-project-files#controlling-dependency-assets\" rel=\"noopener noreferrer nofollow\">PrivateAssets=&#187;all&#187;<\/a>. \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0434\u0430\u0451\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0428\u0430\u0433 2<\/h3>\n<p>\u041c\u0435\u043d\u044f\u0435\u043c .net5.0-windows \u043d\u0430 .net5.0 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u0439 \u0436\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code>dotnet publish ConsoleApp.csproj --self-contained -c Release -r win-x64 \/p:PublishSingleFile=true \/p:PublishTrimmed=true \/p:IncludeAllContentForSelfExtract=true<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0441\u0435\u0433\u043e 18.8\u041c\u0411 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c<\/p>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5d1\/0d9\/f29\/5d10d9f29101cb95edb337a43b88fdf2.png\" width=\"530\" height=\"379\"><figcaption><\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 ?<br \/>\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0434\u0430 !<br \/>\u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0438\u0437 Windows Forms \u0438\u043b\u0438 WPF, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0443 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c \u0432\u0441\u0451 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0438 \u0432\u044b\u0434\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/548442\/\"> https:\/\/habr.com\/ru\/post\/548442\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h2>Target Framework Moniker<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f. \u0412 .NET 5.0 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Windows Forms \u0438\u043b\u0438 WPF \u043d\u0430\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c net5.0:<\/p>\n<pre><code class=\"xml\">&lt;PropertyGroup&gt;   &lt;TargetFramework&gt;net5.0&lt;\/TargetFramework&gt;   &lt;UseWindowsForms&gt;true&lt;\/UseWindowsForms&gt; &lt;\/PropertyGroup&gt;<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Windows Forms \u0438\u043b\u0438 WPF \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443<\/p>\n<pre><code>C:\\Program Files\\dotnet\\sdk\\5.0.201\\Sdks\\Microsoft.NET.Sdk\\targets\\Microsoft.NET.Sdk.DefaultItems.targets(369,5): error NETSDK1136: The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so.<\/code><\/pre>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u0430\u043a \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/frameworks\" rel=\"noopener noreferrer nofollow\">Target Framework Moniker<\/a><\/p>\n<pre><code class=\"xml\">&lt;PropertyGroup&gt;   &lt;TargetFramework&gt;net5.0-windows&lt;\/TargetFramework&gt;   &lt;UseWindowsForms&gt;true&lt;\/UseWindowsForms&gt; &lt;\/PropertyGroup&gt;<\/code><\/pre>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h2>\n<p>\u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u0438\u0437 Microsoft.NET.Sdk\\targets.<br \/>\u0414\u0430\u043b\u0435\u0435 \u0432 dotnet\\sdk\\5.0\\Sdks\\Microsoft.NET.Sdk.WindowsDesktop\\targets\\Microsoft.NET.Sdk.WindowsDesktop.props \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043a\u043e\u0434:<\/p>\n<pre><code class=\"xml\">    &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App\" IsImplicitlyDefined=\"true\"                         Condition=\"('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' == 'true')\"\/&gt;      &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App.WPF\" IsImplicitlyDefined=\"true\"                         Condition=\"('$(UseWPF)' == 'true') And ('$(UseWindowsForms)' != 'true')\"\/&gt;      &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App.WindowsForms\" IsImplicitlyDefined=\"true\"                         Condition=\"('$(UseWPF)' != 'true') And ('$(UseWindowsForms)' == 'true')\"\/&gt;<\/code><\/pre>\n<h2>\u0413\u0434\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e FrameworkReference \u044d\u0442\u043e \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c: <a href=\"https:\/\/github.com\/dotnet\/designs\/blob\/main\/accepted\/2019\/targeting-packs-and-runtime-packs.md\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0434\u0438\u0437\u0430\u0439\u043d\u0430 .NET<\/a> , <a href=\"https:\/\/github.com\/NuGet\/Home\/wiki\/%5BSpec%5D-FrameworkReference-in-NuGet\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f NuGet<\/a><\/p>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u0434\u0435-\u0442\u043e \u0441\u0431\u043e\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0438\u043f \u0438\u0437 Windows Forms \u0438\u043b\u0438 \u0438\u0437 WPF \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 &#8216;net5.0-windows&#8217;.<\/p>\n<p>\u042d\u0442\u043e \u0433\u0440\u043e\u0437\u0438\u0442 \u043d\u0430\u043c \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0439 \u0445\u043b\u0430\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Windows Forms \u0438\u043b\u0438 WPF \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0442, \u0430 \u0435\u0441\u043b\u0438 \u043c\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 60\u041c\u0411 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/p>\n<pre><code class=\"cs\">using System.Windows.Forms;  namespace Library {     public class Demo     {         void ShowForm()         {             var f = new Form();             f.Show();         }     } } <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<pre><code class=\"cs\">using System;  class Program {     public static void Main()     {         Console.WriteLine(\"Hello World!\");     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 Library.Demo.<\/p>\n<p>\u0421\u043e\u0431\u0435\u0440\u0451\u043c \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dotnet publish:<\/p>\n<pre><code class=\"powershell\">dotnet publish ConsoleApp.csproj --self-contained -c Release -r win-x64 \/p:PublishSingleFile=true \/p:PublishTrimmed=true \/p:IncludeAllContentForSelfExtract=true<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 81,8\u041c\u0411 !<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f IncludeAllContentForSelfExtract \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 %TEMP%\\.net \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0437 \u0447\u0435\u0433\u043e \u043e\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442.<\/p>\n<figure class=\"float bordered full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0436\u0435 \u0442\u0430\u043a ?<br \/>\u041c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Library.Demo, \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 PublishTrimmed, \u0430 Windows Forms \u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u0451\u043b.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c dotnet publish \u043f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043c\u043e\u0436\u0435\u043c \u0435\u043c\u0443 !<\/p>\n<h3>\u0428\u0430\u0433 1<\/h3>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"xml\">&lt;Project Sdk=\"Microsoft.NET.Sdk\"&gt;    &lt;PropertyGroup&gt;     &lt;TargetFramework&gt;net5.0&lt;\/TargetFramework&gt;     &lt;!-- \u0423\u043a\u0430\u0436\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u044f\u0432\u043d\u043e --&gt;     &lt;DisableImplicitFrameworkReferences&gt;true&lt;\/DisableImplicitFrameworkReferences&gt;   &lt;\/PropertyGroup&gt;     &lt;ItemGroup&gt;     &lt;!-- .NET Runtime --&gt;     &lt;!-- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0432\u0430\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 PrivateAssets=\"all\" \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 --&gt;     &lt;FrameworkReference Include=\"Microsoft.NETCore.App\" \/&gt;          &lt;!-- Windows Desktop --&gt;     &lt;!-- PrivateAssets=\"all\" - \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0435 \u0438\u0434\u0451\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 --&gt;     &lt;FrameworkReference Include=\"Microsoft.WindowsDesktop.App\" PrivateAssets=\"all\"  \/&gt;          &lt;!-- \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e:       Microsoft.WindowsDesktop.App.WPF       Microsoft.WindowsDesktop.App.WindowsForms --&gt;   &lt;\/ItemGroup&gt;  &lt;\/Project&gt;<\/code><\/pre>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043b\u044f <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/project-sdk\/msbuild-props#disableimplicitframeworkreferences\" rel=\"noopener noreferrer nofollow\">DisableImplicitFrameworkReference<\/a><\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/consume-packages\/package-references-in-project-files#controlling-dependency-assets\" rel=\"noopener noreferrer nofollow\">PrivateAssets=&#187;all&#187;<\/a>. \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0434\u0430\u0451\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0428\u0430\u0433 2<\/h3>\n<p>\u041c\u0435\u043d\u044f\u0435\u043c .net5.0-windows \u043d\u0430 .net5.0 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e\u0439 \u0436\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code>dotnet publish ConsoleApp.csproj --self-contained -c Release -r win-x64 \/p:PublishSingleFile=true \/p:PublishTrimmed=true \/p:IncludeAllContentForSelfExtract=true<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0441\u0435\u0433\u043e 18.8\u041c\u0411 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c<\/p>\n<figure class=\"float full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 ?<br \/>\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0434\u0430 !<br \/>\u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0438\u0437 Windows Forms \u0438\u043b\u0438 WPF, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0443 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c \u0432\u0441\u0451 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0438 \u0432\u044b\u0434\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/548442\/\"> https:\/\/habr.com\/ru\/post\/548442\/<\/a><br \/><\/br><\/br><\/p>\n<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-320098","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320098"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320098\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}