gpt4 book ai didi

visual-studio - 抑制单个编译器错误(例如 NU1603)

转载 作者:行者123 更新时间:2023-12-04 05:43:59 25 4
gpt4 key购买 nike

是否可以抑制 NuGet 错误的单个实例?

我得到下面的 NU1603,我相信我无法解决这个问题,而且我不想为整个项目抑制所有 1603。
NU1603: runtime.native.System.IO.Compression 4.3.0 depends on runtime.win10-arm64.runtime.native.System.IO.Compression (>= 4.3.0) but runtime.win10-arm64.runtime.native.System.IO.Compression 4.3.0 was not found. An approximate best match of runtime.win10-arm64.runtime.native.System.IO.Compression 4.3.1 was resolved.
NuGet package restore failed. Please see Error List window for detailed warnings and errors.

更新

重现警告的步骤是:

  • 创建一个新的 Win IoT Core 后台应用程序,目标是 16299。
  • 添加对 Microsoft.Azure.Devices.Provisioning.Transport.Mqtt 的 NuGet 引用v1.1.1(通过工具 -> NuGet 包管理器 -> 管理解决方案的 NuGet 包...)
  • 构建

  • 尝试修复的额外步骤

    添加对 System.IO.Compression 4.3.0(最新)的 NuGet 引用

    项目文件现在包含
    <PackageReference Include="System.IO.Compression">
    <Version>4.3.0</Version>
    </PackageReference>

    添加 <NoWarn>
    <PackageReference Include="System.IO.Compression">
    <Version>4.3.0</Version>
    <NoWarn>NU1603</NoWarn>
    </PackageReference>

    警告仍然存在。
    现在,

    更新 2 27/06/2018

    这是项目文件:
    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
    <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProjectGuid>{1053DA3E-BC0F-47EA-946C-24EA813DB098}</ProjectGuid>
    <OutputType>winmdobj</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>BackgroundApplication1</RootNamespace>
    <AssemblyName>BackgroundApplication1</AssemblyName>
    <DefaultLanguage>en-US</DefaultLanguage>
    <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
    <TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
    <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
    <EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
    <PackageCertificateKeyFile>BackgroundApplication1_TemporaryKey.pfx</PackageCertificateKeyFile>
    <AppxPackage>true</AppxPackage>
    <ContainsStartupTask>true</ContainsStartupTask>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\ARM\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <DebugType>full</DebugType>
    <PlatformTarget>ARM</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
    <OutputPath>bin\ARM\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <Optimize>true</Optimize>
    <NoWarn>;2008</NoWarn>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>ARM</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <Optimize>true</Optimize>
    <NoWarn>;2008</NoWarn>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <Optimize>true</Optimize>
    <NoWarn>;2008</NoWarn>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
    </PropertyGroup>
    <PropertyGroup>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    </PropertyGroup>
    <ItemGroup>
    <Compile Include="StartupTask.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    </ItemGroup>
    <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
    <SubType>Designer</SubType>
    </AppxManifest>
    <None Include="BackgroundApplication1_TemporaryKey.pfx" />
    </ItemGroup>
    <ItemGroup>
    <Content Include="Properties\Default.rd.xml" />
    <Content Include="Assets\LockScreenLogo.scale-200.png">
    <InProject>false</InProject>
    </Content>
    <Content Include="Assets\SplashScreen.scale-200.png">
    <InProject>false</InProject>
    </Content>
    <Content Include="Assets\Square150x150Logo.scale-200.png">
    <InProject>false</InProject>
    </Content>
    <Content Include="Assets\Square44x44Logo.scale-200.png">
    <InProject>false</InProject>
    </Content>
    <Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
    <InProject>false</InProject>
    </Content>
    <Content Include="Assets\StoreLogo.png">
    <InProject>false</InProject>
    </Content>
    <Content Include="Assets\Wide310x150Logo.scale-200.png">
    <InProject>false</InProject>
    </Content>
    </ItemGroup>
    <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Devices.Provisioning.Transport.Mqtt">
    <Version>1.1.1</Version>
    <NoWarn>NU1603</NoWarn>
    </PackageReference>
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
    <NoWarn>NU1603</NoWarn>
    <Version>6.1.5</Version>
    </PackageReference>
    <PackageReference Include="System.IO.Compression">
    <Version>4.3.0</Version>
    <NoWarn>NU1603</NoWarn>
    </PackageReference>
    </ItemGroup>
    <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0' ">
    <VisualStudioVersion>15.0</VisualStudioVersion>
    </PropertyGroup>
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
    <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    Other similar extension points exist, see Microsoft.Common.targets.
    <Target Name="BeforeBuild">
    </Target>
    <Target Name="AfterBuild">
    </Target>
    -->
    </Project>

    最佳答案

    Is it possible to suppress a single instance of a NuGet error?



    为此,您可以尝试为单个 NuGet 包取消此 NuGet 编译器警告 runtime.native.System.IO.Compression 4.3.0 , 而不是整个项目。

    抑制单个 NuGet 包的特定警告:
  • 在解决方案资源管理器中,选择要取消的 NuGet 包
    编译器警告。
  • 从右键单击或上下文菜单中,选择“属性”。
  • 在包属性的 NoWarn 框中,输入警告
    您想要为这个包抑制的数字。如果你想
    抑制多个警告,使用逗号分隔警告
    数字。

  • 查看详情: Suppress warnings for NuGet packages

    In some cases, you may want to suppress NuGet compiler warnings for a single NuGet package, instead of for an entire project. The warning serves a purpose, so you don't want to suppress it at the project level. For example, one of the NuGet warnings tells you that the package may not be fully compatible with your project. If you suppress it at the project level and later add an additional NuGet package, you would never know if it was producing the compatibility warning.



    希望这可以帮助。

    关于visual-studio - 抑制单个编译器错误(例如 NU1603),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50902568/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com