如何将Wpf项目迁移到新的VS2017格式
我正在将我的项目迁移到新的Visual Studio 2017格式,这对于所有标准库来说都很好用,现在我遇到了我使用Wpf / Xaml的UI库的问题。
我无法弄清楚如何为我的用户控件执行此操作。 旧项目似乎不再有效。
任何人都知道如何做到这一点,或者甚至可能。
Sunburst.NET.Sdk.WPF允许将其用作.NET SDK。 这是WPF应用程序的完整示例,其中将自动包含任何.cs
和.xaml
文件:
WinExe net40
当您使用msbuild
构建此项目时(特别是我没有运行dotnet build
),它会自动从NuGet下载SDK并设置所有内容。
您可以使用下面的模板替换旧的.csproj。 它解决了其他人模板的几个问题。
- 您不必像某些建议那样包含中间
*.g.cs
文件。 -
Main not found
错误。 - 否
Unable to run your project. The "RunCommand" property is not defined.
Unable to run your project. The "RunCommand" property is not defined.
会发生错误。 - 包括已配置的默认设置和资源。
模板:
$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets net47 WinExe full true Designer MSBuild:UpdateDesignTimeXaml Designer MSBuild:UpdateDesignTimeXaml
经过一番搜索和反复试验,我得到了它的工作!
这是最终的wpf csproj:
$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets net451 MyWpfLibrary MyWpfLibrary
以上解决方案适用于Wpf dll,但我还原它,因为Resharper和Visual Studio设计器在此更改后不再起作用。 主要是因为他们无法在设计时配对xaml和代码隐藏。 但该项目编译和工作。
对于wpf可执行文件,您需要执行以下操作:
$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets net451 WinExe MyNamespace MyExe MyExe.ico app.manifest MyNamespace.App