microsoft / VSProjectSystem

Documentation for extending Visual Studio with new types of projects.
Other
311 stars 87 forks source link

PackageReference - Roslyn #218

Closed dazinator closed 7 years ago

dazinator commented 7 years ago

I have been trying to get PackageReference working.

It seems it works fine, in that I can manage nuget packages, and the project file as well as solution explorer, looks correct.

But when editing a csharp file, Roslyn is not finding any of the referenced assemblies from the nuget package.

In the screenshot below, you can see that the nuget package shows up in solution explorer, but the csharp code won't compile because it can't find the assemblies within the referenced nuget package:

image

Here is what my project file looks like:


<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup Label="Globals">
    <CustomProjectExtensionsPath>$(LocalAppData)\CustomProjectSystems\DnnVsProjectSystem\</CustomProjectExtensionsPath>
    <ProjectGuid>b7ef28be-b8ad-48b2-aa93-817b3cfc9deb</ProjectGuid>
  </PropertyGroup>
  <Import Project="$(CustomProjectExtensionsPath)DnnVsProjectSystem.props" />
  <PropertyGroup>
    <OutputType>Library</OutputType>
    <TargetFramework>net45</TargetFramework>
    <OutputPath>bin\$(Configuration)</OutputPath>
    <RootNamespace>DnnVsProjectSystem27</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <None Include="**\*.txt" />
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="obj\**" />
    <EmbeddedResource Remove="obj\**" />
    <None Remove="obj\**" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="DotNetNuke.Core" Version="7.4.2.216" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Web" />
    <Reference Include="System.Windows.Forms" />
  </ItemGroup>
  <ItemGroup>
    <Compile Update="View1.ascx.cs">
      <DependentUpon>View1.ascx</DependentUpon>
      <SubType>ASPXCodeBehind</SubType>
    </Compile>
    <Compile Update="View1.ascx.designer.cs">
      <DependentUpon>View1.ascx</DependentUpon>
      <SubType>ASPXCodeBehind</SubType>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Update="View1.ascx">
      <Generator>DnnAscxDesignerClassGenerator</Generator>
    </None>
  </ItemGroup>

  <Import Project="$(CustomProjectExtensionsPath)DnnVsProjectSystem.targets" />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

I have found that if I:

  1. Unload my project, rename the extension from dnnproj to csproj
  2. Remove the csharp imports

Now everything works fine, and Roslyn has no problem resolving those assemblies in the nuget packages.

I am not sure what I need to do to resolve this problem. As far as I can tell, I have all the same capaiblities, and XAML rule files enabled in my project system... Any guidance appreciated.

dazinator commented 7 years ago

Solution seems to be #219