如何将Wpf项目迁移到新的VS2017格式 [英] How-to migrate Wpf projects to the new VS2017 format
问题描述
我正在将项目迁移到新的Visual Studio 2017格式,该格式对所有标准库都适用,直到现在我在使用Wpf / Xaml的UI库中遇到问题。
I'm migrating my projects to the new visual studio 2017 format which is working nicely for all standard libraries only now I run into problems with my UI libraries where I use Wpf / Xaml.
我不知道如何为用户控件执行此操作。
I cannot figure out howto do this for my user controls. The old item doesn't seem to be valid anymore.
任何人都知道如何执行此操作,或者甚至有可能。
Anybody has an idea howto do this or if it's even possible.
推荐答案
2018年12月13日-。NET Core 3预览版1宣布
December 13th 2018 - .NET Core 3 Preview 1 was announced
.NET Core 3将支持WPF和WinForms应用程序。您可以尝试使用SDK的预览版:
.NET Core 3 will support WPF and WinForms applications. You may try it with Preview version of SDK:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
上一个答案
您可以使用下面的模板替换旧的.csproj。
You can use template below to replace old .csproj with. It resolves couple of issues other people templates had.
- 您不必包括中介
*。g。 cs
文件,如建议的操作。 - 没有
找不到主文件
错误。 - 否
无法运行您的项目。未定义 RunCommand属性。
会发生错误。 - 包括已配置的默认设置和资源。
- You don't have to include intermediary
*.g.cs
files like some suggested to do. - No
Main not found
error will occur. - No
Unable to run your project. The "RunCommand" property is not defined.
error will occur. - Includes already configured default Settings and Resources.
模板:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
<TargetFramework>net47</TargetFramework>
<OutputType>WinExe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<!-- App.xaml -->
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</ApplicationDefinition>
<!-- XAML elements -->
<Page Include="**\*.xaml" Exclude="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</Page>
<Compile Update="**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
<!-- Resources -->
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />
<!-- Settings -->
<None Update="Properties\Settings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
<Compile Update="Properties\Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
</ItemGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
</Project>
这篇关于如何将Wpf项目迁移到新的VS2017格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!