忽略假货组件中的CS7035 "Specified version does not conform to the recommended format"



我使用VS 2015 U1。我使用了一个具有奇怪版本控制的外部库1.0.4056.40164

我为这个库添加了一个.Fakes文件。当构建fakes程序集时,我会收到以下警告:

C:Somewhere.Testf.cs(21,58): warning CS7035: The specified version string does not conform to the recommended format - major.minor.build.revision [C:Somewhere.TestobjDebugFakesrsf.csproj]

我在我的.Fakes文件中指定了:

 <Compilation>
    <Property Name="NoWarn">CS7035,7035</Property>
    <Property Name="DisabledWarnings">7035;1607</Property>
  </Compilation>

运气不佳。

我还将此添加到我的Somewhere.Test.csproj:中

  <NoWarn>CS7035;7035</NoWarn>

由于我不控制这个第三方库,所以在一个干净的解决方案中看到这个警告会让人相当沮丧。

我怎么能仅仅为了这个fakes程序集而抑制它呢?

我已经用成功地抑制了此警告

<NoWarn>7035</NoWarn>

但在我的项目文件中。我需要在所有可能的配置和平台选择中添加它。我有两个,所以我最终得到了:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <DebugSymbols>true</DebugSymbols>
  <DebugType>full</DebugType>
  <Optimize>false</Optimize>
  <OutputPath>bin</OutputPath>
  <DefineConstants>DEBUG;TRACE</DefineConstants>
  <ErrorReport>prompt</ErrorReport>
  <WarningLevel>4</WarningLevel>
  <NoWarn>7035</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  <DebugType>pdbonly</DebugType>
  <Optimize>true</Optimize>
  <OutputPath>bin</OutputPath>
  <DefineConstants>TRACE</DefineConstants>
  <ErrorReport>prompt</ErrorReport>
  <WarningLevel>4</WarningLevel>
  <NoWarn>7035</NoWarn>
</PropertyGroup>

希望这能帮助

在VS2017中,我通过在AssemblyInfo.cs文件中直接添加#pragma warning disable来删除这个讨厌的警告:

#pragma warning disable CS7035 // The specified version string does not conform to the recommended format - major.minor.build.revision 
[assembly: AssemblyFileVersion("1.0.*")]

在我的例子中,它是从csproj中删除<Deterministic>true</Deterministic>

相关内容

最新更新