Skip to content
This repository was archived by the owner on Apr 11, 2020. It is now read-only.

Class Libraries don't support new Razor in VS2017 #1013

Closed
sebastienros opened this issue Mar 8, 2017 · 21 comments
Closed

Class Libraries don't support new Razor in VS2017 #1013

sebastienros opened this issue Mar 8, 2017 · 21 comments

Comments

@sebastienros
Copy link
Member

Repro:
Clone https://github.com/OrchardCMS/Orchard2 on master
Open VS2017
Edit Orchard2\src\Orchard.Cms.Web\Modules\Orchard.Menu\Views_ViewImports.cshtml

image

Expected:

image

/cc
@NTaylorMullen
@BillHiebert
@ToddGrun
@DamianEdwards

@BillHiebert
Copy link

@jrcpereira
Copy link

As a temporary workaround, you can change the project Sdk to Web.

Edit your .csproj within VS'17 and change
<Project Sdk="Microsoft.NET.Sdk">
to
<Project Sdk="Microsoft.NET.Sdk.Web">

Maintain your Target framework as .NETStandard 1.6 if you're using it and be sure to set the Output type to Class library.

You will get tag helpers intellisense, despite no highlight as described in this known issue.

@NTaylorMullen
Copy link

I'd be curious to hear of people's success with @ByteNuts' workaround. I can foresee issues with class libraries that are only desktop but otherwise i'd think it'd work.

@CoskunSunali
Copy link

@NTaylorMullen, I remember trying @ByteNuts's workaround before I landed on this issue but the compilation broke.

As far as I can recall, it complained that a project using the Web SDK should contain a Main entry method.

However, changing the Output Type to Class Library as per @ByteNuts's suggestion seems to have fixed that build-time exception.

Out of curiosity, as you said, the workaround applies to web projects only and could cause issues with desktop-only libraries. Why would you use a library that implements Razor views for a desktop-only library? I am seriously asking to hear if there is a use case for that approach.

@NTaylorMullen
Copy link

Why would you use a library that implements Razor views for a desktop-only library? I am seriously asking to hear if there is a use case for that approach.

In new world, not really a reason to have a desktop-only library. However, it happens, usually when migrating an old library to the new world.

@CoskunSunali
Copy link

I see your point. Thank you.

@thiennn
Copy link

thiennn commented May 16, 2017

any update on this? I have updated to VS 2017 Preview 15.3 and .NET Core 2.0.0 preview 1. But it doesn't work.

@rynowak
Copy link
Member

rynowak commented May 16, 2017

We're looking into this for 15.3 preview2

@rynowak
Copy link
Member

rynowak commented May 23, 2017

@NTaylorMullen fixed for preview2 right?

@NTaylorMullen
Copy link

Yup!

@rynowak
Copy link
Member

rynowak commented May 23, 2017

Ok, thanks everyone for reporting this issue. This will be fixed in VS 2017 15.3-preview 2.

If you have further issues with tooling for Razor please report them via VS Feedback or on aspnet/Razor

@fwitkowski
Copy link

I just have got version 15.3.2 and this is not fixed.

@alexgav
Copy link

alexgav commented Aug 23, 2017 via email

@fwitkowski
Copy link

fwitkowski commented Aug 24, 2017 via email

@alexgav
Copy link

alexgav commented Aug 24, 2017 via email

@fwitkowski
Copy link

fwitkowski commented Aug 24, 2017

I still see many errors in views (but no errors on build)
Like this one when specifying model
image

Or viewbag
image

Or Html.Partial
image

Or many more.
The errors are highlighted in every project we have.
Attaching one of the project files (I did change some names into *** and changed extension to txt - so I can upload it)
Tmp.TalentBrew.Admin.Site.txt

@fwitkowski
Copy link

One more issue. VS2017 does not pick up custom Html Helpers.
VS2015:
image

Same page, VS2017 (only limited list):
image

This is in version 15.3.3

@barrytang
Copy link

To report new issues, use the Report a Problem tool. The GitHub Issue Tracker for the aspnet/Tooling repo is now deprecated in favor of the Report a Problem tool.

If you encounter a problem with Visual Studio, we want to know about it so that we can diagnose and fix it. By using the Report a Problem tool, you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks. See here for more details.

@barrytang
Copy link

@NTaylorMullen @alexgav , is this a known issue?

@rynowak
Copy link
Member

rynowak commented Sep 13, 2017

Looking at the above, my guess is that it's getting the wrong set of namespace imports, possibly because it's falling back to the Razor (non-core) editor.

@rynowak
Copy link
Member

rynowak commented Sep 13, 2017

@fwitkowski could this be your issue? aspnet/Razor#1628

Are tag helpers working?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants