Skip to content

Instantly share code, notes, and snippets.

@duncansmart
Created May 30, 2017 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duncansmart/c4cc9909ca3f149d1b64ca41aa4e4697 to your computer and use it in GitHub Desktop.
Save duncansmart/c4cc9909ca3f149d1b64ca41aa4e4697 to your computer and use it in GitHub Desktop.
Fix for `CS8179: Predefined type 'System.ValueTuple`2' is not defined or imported` in Razor files

Fix for CS8179: Predefined type 'System.ValueTuple2' is not defined or imported` in Razor cshtml files.

Copy to %LOCALAPPDATA%\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Copy to %LOCALAPPDATA%\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\
-->
<PropertyGroup>
<!-- If we have .NET 4.7 use ValueTuple defined in mscorlib -->
<DotNet47Installed Condition=" '$([MSBuild]::GetRegistryValueFromView(`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.7`, null, `NOT_FOUND`, RegistryView.Registry64))' == '' ">True</DotNet47Installed>
<TargetFrameworkVersion Condition="$(TargetFrameworkVersion) == '4.6' And '$(DotNet47Installed)' == 'True'">v4.7</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Reference Condition="'$(DotNet47Installed)' == 'True'" Remove="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL" />
<Reference Condition=" '$(DotNet47Installed)' == 'True' " Include="mscorlib">
<HintPath>$(WINDIR)\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
@chucklu
Copy link

chucklu commented Sep 9, 2019

What's this for? I encounter the problem in mvc project, although I have installed System.ValueTuple through nuget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment