如何解决“必须使用PackageReference”错误? (VS2017,C#,WinForms,WinRT) - c#

将WindowsRuntime添加到WinForms项目后,构建项目失败,并显示错误“必须使用PackageReference”。构建日志更为精确:

C:[...] \ Visual Studio 2017 \ Projects \ Projectname \ packages \ Microsoft.Windows.SDK.Contracts.10.0.18362.2005 \ build \ Microsoft.Windows.SDK.Contracts.targets(4,5):错误:必须使用PackageReference

这是我所做的:

安装包Microsoft.Windows.SDK.Contracts

提及:

C:\ Program Files(x86)\ Reference Assemblys \ Microsoft \ Framework.NETCore \ v4.5 \ System.Runtime.WindowsRuntime.dll,
C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ Facades \ System.Runtime.dll
C:\ Program Files(x86)\参考程序集\ Microsoft \ Framework.NETFramework \ v4.5 \ Facades \ System.Threading.Tasks.dll
C:\ Program Files(x86)\参考程序集\ Microsoft \ Framework.NETFramework \ v4.5 \ Facades \ System.IO.dll
C:\ Program Files(x86)\ Reference Assemblys \ Microsoft \ Framework.NETFramework \ v4.5 \ Facades \ System.Runtime.InteropServices.WindowsRuntime.dll。

.NET版本可能有问题吗?在项目的packages.config中有4.6,而项目目标是4.5。

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" targetFramework="net45"/>
<package id="System.Runtime.WindowsRuntime" version="4.6.0" targetFramework="net45" />
<package id="System.Runtime.WindowsRuntime.UI.Xaml" version="4.6.0" targetFramework="net45" />
</packages>

没有编译错误,只有这个奇怪的PackageReference错误。

谢谢您的智慧。

参考方案

VS2019-> Solution Explorer->右键单击References->“将packages.config迁移到PackageReference”

Windows Phone WNS通知导航到特定页面 - c#

它是Windows运行时,Windows Phone专用项目。我正在使用Azure和Azure通知中心。所以我的问题是,有谁愿意如何导航到某些特定页面并发送ID等参数。这是我的吐司模板,如字符串中所述: var toast = @"<toast><visual><binding template=""…

当回复有时是一个对象有时是一个数组时,如何在使用改造时解析JSON回复? - java

我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…

Mongo汇总 - javascript

我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …

如何在Wiremock中为JUNIT匹配精确的json - java

我正在使用Wiremock在Spring启动应用程序中模拟Junit的REST服务。我的问题是,我无法匹配多个匹配模式。 Junit.javaStringValuePattern pattern = WireMock.matching(".*"); givenThat(post(urlEqualTo("/softwares�…

使用Selenium和python在textBox中快速编写 - javascript

我正在使用Selenium和Python(Chorme驱动程序)在文本框中编写内容,但是有很多文本框,我需要它来更快地填充它们。我使用一系列driver.find_element_by_xpath("//input[@class='string required' and @id='order_billing_name…