1
Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(161, 5): Assembly location for Razor SDK Tasks was not specified.
The most likely cause is an older incompatible version of Microsoft.NET.Sdk.Razor,
or Microsoft.NET.Sdk.Web used by this project.
Please target a newer version of the .NET Core SDK.

I have the below package reference

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>LegalRegTech.Web.Public</AssemblyName>
    <OutputType>Exe</OutputType>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    <LangVersion>7.2</LangVersion>
  </PropertyGroup>

<ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
  </ItemGroup>
</Project>

By adding Microsoft.NET.Sdk.Razor still not able to resolve the issue. Tried the solution from this Assembly location for Razor SDK Tasks was not specified but still not able to solve the issue

1
  • Hi @San Jaisy, Your packages all are related to 2.2, but your target framework is 2.1. Suggest you can keep the same. You can create a new .NET Core 2.1 template project , and compare the new one's csproj file with the old one's . Pay attention to TargetFramework and related PackageReference , check the Version variable.
    – Rena
    Commented Jan 29, 2022 at 5:58

1 Answer 1

0

It worked on the build server, after added this Nuget package:

Microsoft.NET.Sdk.Razor

Since I added the Net.SDK.Razor package, it builds successfully.

I had also added Microsoft.AspNetCore.Razor.Design, but only Microsoft.NET.Sdk.Razor is actually needed.

resource

Not the answer you're looking for? Browse other questions tagged or ask your own question.