Visual Studio 2015
Build failing due to [Obsolete]?
This would only occur if “Treat Warnings As Errors” is enabled, and there is a method with the [Obsolete] attribute.
Method 1: Downgrade error to warning
Add <WarningsNotAsErrors>612,618</WarningsNotAsErrors>
in the .csproj
file (repeat for all sections):
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<WarningsNotAsErrors>612,618</WarningsNotAsErrors>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
If dealing with many .csproj files
, see Appendix A: Notepad++ for search and replace
.
Method 2: Ignore error in file
Note: This method is not recommended, because it hides the warnings for methods marked [Obsolete]. We still want to see a list of
all calls to obsolete methods so we can upgrade them.
Use #pragma warning disable 612,618
Method 3: Ignore error in project
Note: This method is not recommended, because it hides the warnings for methods marked [Obsolete]. We still want to see a list of
all calls to obsolete methods so we can upgrade them.
Edit the project (repeat for all sections):
Method 4: Ignore error in project
Note: This method is not recommended, because it hides the warnings for methods marked [Obsolete]. We still want to see a list of
all calls to obsolete methods so we can upgrade them.
Manually edit your .csproj to disable warnings for specific errors. Add the tag <NoWarn>612,618</NoWarn>
(repeat for all sections):
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<NoWarn>612,618</NoWarn>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
Appendix A: Notepad++ for search and replace
Have a lot of files? No problem!
Open all .csproj
files in NotePad++, then:
- Find:
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- Replace:
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>\n\t<WarningsNotAsErrors>612,618</WarningsNotAsErrors>