<legend id='dU7YI'><style id='dU7YI'><dir id='dU7YI'><q id='dU7YI'></q></dir></style></legend>

    • <bdo id='dU7YI'></bdo><ul id='dU7YI'></ul>

      <small id='dU7YI'></small><noframes id='dU7YI'>

    1. <i id='dU7YI'><tr id='dU7YI'><dt id='dU7YI'><q id='dU7YI'><span id='dU7YI'><b id='dU7YI'><form id='dU7YI'><ins id='dU7YI'></ins><ul id='dU7YI'></ul><sub id='dU7YI'></sub></form><legend id='dU7YI'></legend><bdo id='dU7YI'><pre id='dU7YI'><center id='dU7YI'></center></pre></bdo></b><th id='dU7YI'></th></span></q></dt></tr></i><div id='dU7YI'><tfoot id='dU7YI'></tfoot><dl id='dU7YI'><fieldset id='dU7YI'></fieldset></dl></div>

      <tfoot id='dU7YI'></tfoot>
    2. WPF 应用程序使用新的 csproj 格式

      WPF App Using new csproj format(WPF 应用程序使用新的 csproj 格式)

        • <legend id='FdjS7'><style id='FdjS7'><dir id='FdjS7'><q id='FdjS7'></q></dir></style></legend>

              <tbody id='FdjS7'></tbody>
              <bdo id='FdjS7'></bdo><ul id='FdjS7'></ul>

                <tfoot id='FdjS7'></tfoot>

                <i id='FdjS7'><tr id='FdjS7'><dt id='FdjS7'><q id='FdjS7'><span id='FdjS7'><b id='FdjS7'><form id='FdjS7'><ins id='FdjS7'></ins><ul id='FdjS7'></ul><sub id='FdjS7'></sub></form><legend id='FdjS7'></legend><bdo id='FdjS7'><pre id='FdjS7'><center id='FdjS7'></center></pre></bdo></b><th id='FdjS7'></th></span></q></dt></tr></i><div id='FdjS7'><tfoot id='FdjS7'></tfoot><dl id='FdjS7'><fieldset id='FdjS7'></fieldset></dl></div>

                <small id='FdjS7'></small><noframes id='FdjS7'>

                本文介绍了WPF 应用程序使用新的 csproj 格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在尝试将使用旧 csproj 格式定义的 WPF 项目迁移到 VS 2017 下的新格式.

                I am experimenting with migrating a WPF project, defined using the old csproj format, to the new format under VS 2017.

                使用我在 如何将 Wpf 项目迁移到新的 VS2017 格式.

                但我一直无法克服这个错误:

                But I'm stuck at getting past this error:

                错误 CS5001:程序不包含适合的静态主要"方法入口点

                error CS5001: Program does not contain a static 'Main' method suitable for an entry point

                我的新式csproj文件如下:

                My new-style csproj file is as follows:

                <Project Sdk="Microsoft.NET.Sdk">
                
                  <PropertyGroup>
                    <LanguageTargets>$(MSBuildExtensionsPath)$(VisualStudioVersion)BinMicrosoft.CSharp.targets</LanguageTargets>
                    <OutputType>winexe</OutputType>
                    <TargetFramework>net47</TargetFramework>
                    <ApplicationIcon />
                    <OutputTypeEx>winexe</OutputTypeEx>
                    <StartupObject />
                  </PropertyGroup>
                
                  <ItemGroup>
                    <EmbeddedResource Update="PropertiesResources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
                    <Compile Update="PropertiesResources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
                    <Compile Update="Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
                    <None Update="Settings.settings" LastGenOutput="Settings.Designer.cs" Generator="SettingsSingleFileGenerator" />
                
                    <Page Include="***.xaml" SubType="Designer" Generator="MSBuild:Compile" />
                    <Compile Update="***.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
                
                    <Resource Include="assets*.*" />
                  </ItemGroup>
                
                  <ItemGroup>
                    <PackageReference Include="Autofac" Version="4.6.0" />
                    <PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="4.0.0" />
                    <PackageReference Include="Extended.Wpf.Toolkit" Version="3.0.0" />
                    <PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.0.8" />
                    <PackageReference Include="MaterialDesignColors" Version="1.1.3" />
                    <PackageReference Include="MaterialDesignThemes" Version="2.3.0.823" />
                    <PackageReference Include="MvvmLightLibs" Version="5.3.0" />
                    <PackageReference Include="Serilog" Version="2.4.0" />
                    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
                  </ItemGroup>
                
                  <ItemGroup>
                    <ProjectReference Include="....WPFUtilitiesJ4JUIJ4JUI.csproj" />
                  </ItemGroup>
                
                  <ItemGroup>
                    <Reference Include="System.ComponentModel.DataAnnotations" />
                  </ItemGroup>
                
                  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
                </Project>
                

                如何配置 csproj 文件以便构建入口点?

                How do I configure the csproj file so that entry point gets built?

                更新

                根据有关 ApplicationDefinition 的提示,我能够编译项目.我无法在 BuildAction 中设置 ApplicationDefinition ——这不是选择之一——但必须手动编辑 csproj 文件以包含它.这是工作版本:

                Based on the tip about ApplicationDefinition I was able to get the project to compile. I could not set ApplicationDefinition in the BuildAction -- it was not one of the choices -- but had to edit the csproj file manually to include it. Here's the working version:

                <Project Sdk="Microsoft.NET.Sdk">
                
                  <PropertyGroup>
                    <LanguageTargets>$(MSBuildExtensionsPath)$(VisualStudioVersion)BinMicrosoft.CSharp.targets</LanguageTargets>
                    <OutputType>winexe</OutputType>
                    <TargetFramework>net47</TargetFramework>
                    <ApplicationIcon />
                    <OutputTypeEx>winexe</OutputTypeEx>
                    <StartupObject />
                  </PropertyGroup>
                
                  <ItemGroup>
                    <EmbeddedResource Update="PropertiesResources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
                    <Compile Update="PropertiesResources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
                    <Compile Update="Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
                    <None Update="Settings.settings" LastGenOutput="Settings.Designer.cs" Generator="SettingsSingleFileGenerator" />
                
                    <Page Include="***.xaml" SubType="Designer" Generator="MSBuild:Compile" Exclude="App.xaml" />
                    <Compile Update="***.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
                
                    <Resource Include="assets*.*" />
                
                    <ApplicationDefinition Include="App.xaml">
                      <Generator>MsBuild:Compile</Generator>
                      <SubType>Designer</SubType>
                    </ApplicationDefinition>
                
                  </ItemGroup>
                
                  <ItemGroup>
                    <PackageReference Include="Autofac" Version="4.6.0" />
                    <PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="4.0.0" />
                    <PackageReference Include="Extended.Wpf.Toolkit" Version="3.0.0" />
                    <PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.0.8" />
                    <PackageReference Include="MaterialDesignColors" Version="1.1.3" />
                    <PackageReference Include="MaterialDesignThemes" Version="2.3.0.823" />
                    <PackageReference Include="MvvmLightLibs" Version="5.3.0" />
                    <PackageReference Include="Serilog" Version="2.4.0" />
                    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
                  </ItemGroup>
                
                  <ItemGroup>
                    <ProjectReference Include="....WPFUtilitiesJ4JUIJ4JUI.csproj" />
                  </ItemGroup>
                
                  <ItemGroup>
                    <Reference Include="System.ComponentModel.DataAnnotations" />
                  </ItemGroup>
                
                  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
                </Project>
                

                还要注意指令上的排除过滤器.有必要阻止 MSBuild 尝试编译 App.xaml.cs 两次.

                Note also the Exclude filter on the directive. It's necessary to keep MSBuild from attempting to compile App.xaml.cs twice.

                推荐答案

                需要将App.xaml的Build Action设置为ApplicationDefinition.结果是您的 csproj 文件中的以下项目:

                You need to set the Build Action of App.xaml to ApplicationDefinition. The result is the following item in your csproj file:

                <ApplicationDefinition Include="App.xaml">
                  <Generator>MSBuild:Compile</Generator>
                  <SubType>Designer</SubType>
                </ApplicationDefinition>
                

                这篇关于WPF 应用程序使用新的 csproj 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                  <tbody id='AacK7'></tbody>
                <legend id='AacK7'><style id='AacK7'><dir id='AacK7'><q id='AacK7'></q></dir></style></legend>
                  <i id='AacK7'><tr id='AacK7'><dt id='AacK7'><q id='AacK7'><span id='AacK7'><b id='AacK7'><form id='AacK7'><ins id='AacK7'></ins><ul id='AacK7'></ul><sub id='AacK7'></sub></form><legend id='AacK7'></legend><bdo id='AacK7'><pre id='AacK7'><center id='AacK7'></center></pre></bdo></b><th id='AacK7'></th></span></q></dt></tr></i><div id='AacK7'><tfoot id='AacK7'></tfoot><dl id='AacK7'><fieldset id='AacK7'></fieldset></dl></div>

                    <small id='AacK7'></small><noframes id='AacK7'>

                    • <tfoot id='AacK7'></tfoot>

                          <bdo id='AacK7'></bdo><ul id='AacK7'></ul>