aspnet / Razor

[Archived] Parser and code generator for CSHTML files used in view pages for MVC web apps. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
883 stars 226 forks source link

Build error: IntegrationTestBase.cs(130,8): Target frameworks need to be updated #2728

Closed KirillOsenkov closed 5 years ago

KirillOsenkov commented 5 years ago
  1. git clone https://github.com/aspnet/razor
  2. nuget restore
  3. msbuild /bl

Expected: builds fine

Actual:

Errors
    Language\IntegrationTests\IntegrationTestBase.cs(130,8): error CS1029: #error: 'Target frameworks need to be updated            ' [C:\razor\test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj]
    Language\Legacy\ParserTestBase.cs(74,8): error CS1029: #error: 'Target frameworks need to be updated.' [C:\razor\test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj]

This is because neither NETFRAMEWORK nor NETCOREAPP define is defined.

I realize the instructions say to use build.cmd (which will eventually call run.ps1 which will use KoreBuild), however it feels like it's very close to be able to build just by using nuget restore + msbuild.

I'm filing this bug in hope that there's an easy default somewhere that will allow this repo to build by just calling msbuild /r. This is an ideal that repos in our ecosystem should strive towards, because custom tooling such as build.cmd or KoreBuild is not standard and so creates barriers that are probably avoidable.

pranavkm commented 5 years ago

@KirillOsenkov support for NETFRAMEWORK \ NETCOREAPP constants was added as part of the 2.1.3 SDK. If you don't have it installing, running .\build /t:Restore should install it for you. You can run dotnet build once it's in your PATH

KirillOsenkov commented 5 years ago

Thanks! Shouldn't it default to NETFRAMEWORK in that case? Or is having an SDK a prerequisite?

pranavkm commented 5 years ago

Since we very commonly cross-compile in the AspNetCore repos, having it error was a safer bet than defaulting and using the incorrect API. Our repos often times use new SDK features (for instance I've seen a few places with FrameworkReference items that's still in 3.0 preview) and may not build with an older Sdk. Letting the build install the Sdk it thinks works is generally the path of least resistance.

KirillOsenkov commented 5 years ago

Understood. You decide whether to close this issue or if you still want to do something about it.

It's just strange that that one error seems to be the only place where the build breaks if you just build "by default". I'd expect either a clean build or a lot of errors.

mkArtakMSFT commented 5 years ago

Thanks @KirillOsenkov and @pranavkm! Closing this as this repo will eventually move to AspNetCore where build will be slightly different, while the rules may still be applicable.