Giter Site home page Giter Site logo

ASPCONFIG Could not load file or assembly 'Microsoft.CSharp, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. about msbuild.sdk.systemweb HOT 3 CLOSED

czemacleod avatar czemacleod commented on June 5, 2024
ASPCONFIG Could not load file or assembly 'Microsoft.CSharp, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

from msbuild.sdk.systemweb.

Comments (3)

chenghuang-mdsol avatar chenghuang-mdsol commented on June 5, 2024 1

The SDK includes the logic for the MvcBuildViews property and target. So you don't need the target in your project file.
By default, it tries to run the compiler in release mode to precompile and views and other code.

You can override this behaviour by adding

    <MvcBuildViews>false</MvcBuildViews>

to a PropertyGroup

Again - if you want to use automatic binding redirects see Autogenerating Binding Redirects
Replace

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
   <OverwriteAppConfigWithBindingRedirects>true</OverwriteAppConfigWithBindingRedirects>

As I don't have CrystalReports, or some of the other Nuget Packages, and references, nor the web.config file you are using, I cannot fully test your project.
But using the template file's web.config and stripping out the other stuff, it compiles fine on my machine in both debug and release mode ;)

I suggest you check if there is a bad binding redirection in your web.config file, perhaps trying to redirect Microsoft.CSharp to version 5.0.0.0?
You may also need to check if you have any web.config files in subfolders.
You may need something like

  <Target Name="UpdateWebConfigBindingRedirects" AfterTargets="CopyFilesToOutputDirectory">
    <Copy SourceFiles="$(OutDir)$(AssemblyName).dll.config" DestinationFiles="web.config" />
    <Copy SourceFiles="$(OutDir)$(AssemblyName).dll.config" DestinationFiles="Views\web.config" />
    <Copy SourceFiles="$(OutDir)$(AssemblyName).dll.config" DestinationFiles="Areas\myrandomarea\Views\web.config" />
  </Target>

Although it will depend on your specific web.config file - any location based entries may confuse the matter.

buggyproject.csproj

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.49">
  <PropertyGroup>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    
    <OverwriteAppConfigWithBindingRedirects>true</OverwriteAppConfigWithBindingRedirects>

    <!--<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>-->
    <TargetFramework>net471</TargetFramework>
    <AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="Modules\Architect\Controls\LibraryIconControl.style" />
    <EmbeddedResource Include="Modules\DDE\Controls\DataPageLocatorSearchList.js" />
    <EmbeddedResource Include="Modules\Translations\Controls\StringTypeTable.js" />
    <EmbeddedResource Include="Modules\Translations\Controls\TranslationTextBox.js" />
  </ItemGroup>
  <ItemGroup><!-- some project refs -->
  
    <Compile Remove="Modules\**" />
    <Content Remove="Modules\**" />
    <EmbeddedResource Remove="Modules\**" />
    <None Remove="Modules\**" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Web.Mvc" />
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="WindowsBase" />
    <Reference Include="netstandard" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="CommonServiceLocator" Version="1.0.0" />
    <PackageReference Include="Dapper" Version="1.60.5" />
    <PackageReference Include="DapperWrapper" Version="0.3.0" />
    <PackageReference Include="DocumentFormat.OpenXml" Version="2.5.0" />
    <PackageReference Include="log4net" Version="2.0.5" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="3.0.50813.1" />
    <PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.7" />
    <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.9.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="3.9.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
    <PackageReference Include="SonarAnalyzer.CSharp" Version="6.6.0.3969" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
    <PackageReference Include="System.Text.Encodings.Web" Version="5.0.0" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
    <PackageReference Include="Unity" Version="5.3.1" />
  </ItemGroup>
  <ItemGroup>
    <WebReferences Include="Web References\" />
    <WebReferenceUrl Include="http://localhost/MedidataRAVE/Services/CacheReset.asmx">
      <RelPath>Web References\ResetService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://localhost/MedidataRave/Services/HealthService.asmx">
      <RelPath>Web References\HealthMonitorService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
      <UpdateFromURL>http://localhost/MedidataRave/Services/HealthService.asmx</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>
      </CachedAppSettingsObjectName>
      <CachedSettingsPropName>
      </CachedSettingsPropName>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://localhost/MedidataRave/services/versionservice.asmx%3fwsdl">
      <RelPath>Web References\VersionService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
      <UpdateFromURL>http://localhost/MedidataRave/services/versionservice.asmx%3fwsdl</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>
      </CachedAppSettingsObjectName>
      <CachedSettingsPropName>
      </CachedSettingsPropName>
    </WebReferenceUrl>
  </ItemGroup>
  <ItemGroup>
    <Content Update="Web.config">
    </Content>
    <Content Update="*.tmpl">
    </Content>
    <Content Update="*.config.tmpl">
    </Content>
  </ItemGroup>
  <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
  </Target>
</Project>

web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.8" />
    <httpRuntime targetFramework="4.8" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.1" newVersion="5.0.0.1" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Data.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.Tracing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Globalization.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Sockets" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Security.SecureString" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Overlapped" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Thank you for the auto binding redirect tip. I crafted a similar script to get rid of the error. I am closing the ticket.

from msbuild.sdk.systemweb.

chenghuang-mdsol avatar chenghuang-mdsol commented on June 5, 2024

my project file:

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.49">
  <PropertyGroup>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    <TargetFramework>net471</TargetFramework>
    <AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="Modules\Architect\Controls\LibraryIconControl.style" />
    <EmbeddedResource Include="Modules\DDE\Controls\DataPageLocatorSearchList.js" />
    <EmbeddedResource Include="Modules\Translations\Controls\StringTypeTable.js" />
    <EmbeddedResource Include="Modules\Translations\Controls\TranslationTextBox.js" />
  </ItemGroup>
  <ItemGroup>
    <! -- some project refs -->
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Web.Mvc" />
    <Reference Include="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="CrystalDecisions.Windows.Forms, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" />
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="WindowsBase" />
    <Reference Include="PostSharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\ExternalAssemblies\PostSharp.dll</HintPath>
    </Reference>
    <Reference Include="netstandard" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="CommonServiceLocator" Version="1.0.0" />
    <PackageReference Include="Dapper" Version="1.60.5" />
    <PackageReference Include="DapperWrapper" Version="0.3.0" />
    <PackageReference Include="DocumentFormat.OpenXml" Version="2.5.0" />
    <PackageReference Include="log4net" Version="2.0.5" />
    <PackageReference Include="Medidata.Cloud.ExcelLoader" Version="1.0.3" />
    <PackageReference Include="Medidata.Cloud.Thermometer.RaveCommon" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="3.0.50813.1" />
    <PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.7" />
    <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.9.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="3.9.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
    <PackageReference Include="SonarAnalyzer.CSharp" Version="6.6.0.3969" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
    <PackageReference Include="System.Text.Encodings.Web" Version="5.0.0" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
    <PackageReference Include="Unity" Version="5.3.1" />
  </ItemGroup>
  <ItemGroup>
    <WebReferences Include="Web References\" />
    <WebReferenceUrl Include="http://localhost/MedidataRAVE/Services/CacheReset.asmx">
      <RelPath>Web References\ResetService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://localhost/MedidataRave/Services/HealthService.asmx">
      <RelPath>Web References\HealthMonitorService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
      <UpdateFromURL>http://localhost/MedidataRave/Services/HealthService.asmx</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>
      </CachedAppSettingsObjectName>
      <CachedSettingsPropName>
      </CachedSettingsPropName>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://localhost/MedidataRave/services/versionservice.asmx%3fwsdl">
      <RelPath>Web References\VersionService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
      <UpdateFromURL>http://localhost/MedidataRave/services/versionservice.asmx%3fwsdl</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>
      </CachedAppSettingsObjectName>
      <CachedSettingsPropName>
      </CachedSettingsPropName>
    </WebReferenceUrl>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Modules\Reporting\Controls\" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="..\..\version\AssemblyInfoGlobal.cs">
      <Link>AssemblyInfoGlobal.cs</Link>
    </Compile>
    <Content Update="Web.config">
    </Content>
    <Content Update="*.tmpl">
    </Content>
    <Content Update="*.config.tmpl">
    </Content>
  </ItemGroup>
  <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
  </Target>
</Project>

from msbuild.sdk.systemweb.

CZEMacLeod avatar CZEMacLeod commented on June 5, 2024

The SDK includes the logic for the MvcBuildViews property and target. So you don't need the target in your project file.
By default, it tries to run the compiler in release mode to precompile and views and other code.

You can override this behaviour by adding

    <MvcBuildViews>false</MvcBuildViews>

to a PropertyGroup

Again - if you want to use automatic binding redirects see Autogenerating Binding Redirects
Replace

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
   <OverwriteAppConfigWithBindingRedirects>true</OverwriteAppConfigWithBindingRedirects>

As I don't have CrystalReports, or some of the other Nuget Packages, and references, nor the web.config file you are using, I cannot fully test your project.
But using the template file's web.config and stripping out the other stuff, it compiles fine on my machine in both debug and release mode ;)

I suggest you check if there is a bad binding redirection in your web.config file, perhaps trying to redirect Microsoft.CSharp to version 5.0.0.0?
You may also need to check if you have any web.config files in subfolders.
You may need something like

  <Target Name="UpdateWebConfigBindingRedirects" AfterTargets="CopyFilesToOutputDirectory">
    <Copy SourceFiles="$(OutDir)$(AssemblyName).dll.config" DestinationFiles="web.config" />
    <Copy SourceFiles="$(OutDir)$(AssemblyName).dll.config" DestinationFiles="Views\web.config" />
    <Copy SourceFiles="$(OutDir)$(AssemblyName).dll.config" DestinationFiles="Areas\myrandomarea\Views\web.config" />
  </Target>

Although it will depend on your specific web.config file - any location based entries may confuse the matter.

buggyproject.csproj

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.49">
  <PropertyGroup>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    
    <OverwriteAppConfigWithBindingRedirects>true</OverwriteAppConfigWithBindingRedirects>

    <!--<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>-->
    <TargetFramework>net471</TargetFramework>
    <AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="Modules\Architect\Controls\LibraryIconControl.style" />
    <EmbeddedResource Include="Modules\DDE\Controls\DataPageLocatorSearchList.js" />
    <EmbeddedResource Include="Modules\Translations\Controls\StringTypeTable.js" />
    <EmbeddedResource Include="Modules\Translations\Controls\TranslationTextBox.js" />
  </ItemGroup>
  <ItemGroup><!-- some project refs -->
  
    <Compile Remove="Modules\**" />
    <Content Remove="Modules\**" />
    <EmbeddedResource Remove="Modules\**" />
    <None Remove="Modules\**" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Web.Mvc" />
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="WindowsBase" />
    <Reference Include="netstandard" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="CommonServiceLocator" Version="1.0.0" />
    <PackageReference Include="Dapper" Version="1.60.5" />
    <PackageReference Include="DapperWrapper" Version="0.3.0" />
    <PackageReference Include="DocumentFormat.OpenXml" Version="2.5.0" />
    <PackageReference Include="log4net" Version="2.0.5" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="3.0.50813.1" />
    <PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.7" />
    <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.9.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="3.9.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
    <PackageReference Include="SonarAnalyzer.CSharp" Version="6.6.0.3969" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
    <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
    <PackageReference Include="System.Text.Encodings.Web" Version="5.0.0" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
    <PackageReference Include="Unity" Version="5.3.1" />
  </ItemGroup>
  <ItemGroup>
    <WebReferences Include="Web References\" />
    <WebReferenceUrl Include="http://localhost/MedidataRAVE/Services/CacheReset.asmx">
      <RelPath>Web References\ResetService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://localhost/MedidataRave/Services/HealthService.asmx">
      <RelPath>Web References\HealthMonitorService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
      <UpdateFromURL>http://localhost/MedidataRave/Services/HealthService.asmx</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>
      </CachedAppSettingsObjectName>
      <CachedSettingsPropName>
      </CachedSettingsPropName>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://localhost/MedidataRave/services/versionservice.asmx%3fwsdl">
      <RelPath>Web References\VersionService\</RelPath>
      <UrlBehavior>Static</UrlBehavior>
      <UpdateFromURL>http://localhost/MedidataRave/services/versionservice.asmx%3fwsdl</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>
      </CachedAppSettingsObjectName>
      <CachedSettingsPropName>
      </CachedSettingsPropName>
    </WebReferenceUrl>
  </ItemGroup>
  <ItemGroup>
    <Content Update="Web.config">
    </Content>
    <Content Update="*.tmpl">
    </Content>
    <Content Update="*.config.tmpl">
    </Content>
  </ItemGroup>
  <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
  </Target>
</Project>

web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.8" />
    <httpRuntime targetFramework="4.8" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.1" newVersion="5.0.0.1" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Data.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.Tracing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Globalization.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Sockets" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Security.SecureString" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Overlapped" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

from msbuild.sdk.systemweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.