Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
141 views
in Technique[技术] by (71.8m points)

c# - How-to migrate Wpf projects to the new VS2017 format

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

December 13th 2018 - .NET Core 3 Preview 1 was announced

.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>

Previous answer

You can use template below to replace old .csproj with. It resolves couple of issues other people templates had.

  1. You don't have to include intermediary *.g.cs files like some suggested to do.
  2. No Main not found error will occur.
  3. No Unable to run your project. The "RunCommand" property is not defined. error will occur.
  4. Includes already configured default Settings and Resources.

Template:

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
  <PropertyGroup>
    <LanguageTargets>$(MSBuildExtensionsPath)$(VisualStudioVersion)BinMicrosoft.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="PropertiesResources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
    <Compile Update="PropertiesResources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />

    <!-- Settings -->
    <None Update="PropertiesSettings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
    <Compile Update="PropertiesSettings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />

  </ItemGroup>

  <ItemGroup>
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="System.Xaml" />
    <Reference Include="WindowsBase" />
  </ItemGroup>
</Project>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...