Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Class library has lost all intellisense in VS2017 after auto-migration #5975

Closed
svallis opened this issue Mar 16, 2017 · 18 comments
Closed

Class library has lost all intellisense in VS2017 after auto-migration #5975

svallis opened this issue Mar 16, 2017 · 18 comments
Assignees
Labels

Comments

@svallis
Copy link

svallis commented Mar 16, 2017

After migrating a VS2015 MVC Core application with two projects (web app and class library) to VS2017 I've lost intellisense on all views within the class library. Pretty much everything in every single view is broken, so I'm sure it's something fairly basic that the migration tool didn't take care of for me. Even the @model directive in each razor view is an error.

The csproj looks like this:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AssemblyName>Library</AssemblyName>
    <PackageId>Library</PackageId>
    <PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
    <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
    <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
  </PropertyGroup>

  <ItemGroup>
    <EmbeddedResource Include="Views\**" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="1.1.0" />
  </ItemGroup>

</Project>

I tried duplicating the web.config from the web application to the root of the class library but that didn't help. I've also tried moving over various entries from the web application's csproj file, but to no avail.

The entire project still builds, runs and publishes perfectly. I only see errors if I have a cshtml file from the library open in VS.

@pranavkm
Copy link
Contributor

@NTaylorMullen isn't this the same issue @sebastienros is running in to?

@sebastienros
Copy link
Member

I would say definitely.

@svallis try to use <Project Sdk="Microsoft.NET.Sdk.Web"> in the meantime. It's kind of wrong but it should give you intellisense. Haven't tried it myself so far. Right @pranavkm?

@svallis
Copy link
Author

svallis commented Mar 16, 2017

@sebastienros Can confirm that brings back intellisense, thanks. Any downsides to switching the SDK? If there's anything I can help with re diagnosis/resolution please let me know.

@pranavkm
Copy link
Contributor

@vijayrkn would probably know best - are there any side effects to changing the SDK of a class library to Microsoft.NET.Sdk.Web?

@vijayrkn
Copy link

There shouldn't be any side effects to changing the Net Sdk to Web Sdk. I don't know why intellisense is not working otherwise.

@svallis
Copy link
Author

svallis commented Mar 16, 2017

@vijayrkn Publishing inside a docker container breaks with the Microsoft.NET.Sdk.Web SDK specified. Changing back to Microsoft.NET.Sdk resolves the issue (but breaks intellisense again.)

CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/tmp/src/Library/Library.csproj]

Edit: Same error occurs just when building within Visual Studio. So it's a choice between being able to build and run vs. having intellisense, unfortunately!

@vijayrkn
Copy link

@NTaylorMullen - is websdk needed for intellisense ?

@pranavkm
Copy link
Contributor

@svallis, sorry I missed seeing your comment about the build failure. Try setting <OutputType>Library</OutputType> to your project. The Web SDK defaults to making the project an executable.

@svallis
Copy link
Author

svallis commented Mar 21, 2017

Perfect, thanks @pranavkm!

@purplepiranha
Copy link

Excellent, finally working after trying various things all day.

Found that you also needed to reopen the solution for the intellisense to start working.

Thanks @pranavkm

@Eilon
Copy link
Member

Eilon commented May 13, 2017

@rynowak - parking on your plate because this seems to be in the ballpark of what you've been up to.

@rynowak
Copy link
Member

rynowak commented May 13, 2017

@Eilon sorry what's this about? Is this about tag helper intellisense in class libraries?

@Eilon
Copy link
Member

Eilon commented May 15, 2017

@rynowak - that's what it looks like...?

@svallis
Copy link
Author

svallis commented May 15, 2017

Not just tag helper intellisense - all intellisence is lost when the SDK is set to Microsoft.NET.Sdk instead of Microsoft.NET.Sdk.Web. That may well be how things should be working, but the VS2017 auto-conversion tool was setting libraries to the former SDK, and therefore breaking intellisense. If the only problem that's really here is with the project converter though, then it may go away of its own accord.

@thiennn
Copy link

thiennn commented May 16, 2017

Look like the same issue aspnet/Tooling#1013

@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

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

No branches or pull requests

9 participants