Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PackageReference - custom project system #4891

Closed
dazinator opened this issue Mar 26, 2017 · 2 comments
Closed

PackageReference - custom project system #4891

dazinator opened this issue Mar 26, 2017 · 2 comments

Comments

@dazinator
Copy link

dazinator commented Mar 26, 2017

Hi,

I am developing my own custom project type (CPS), and trying to leverage <PackageReference>.
My custom project file (template) looks like this:

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

  <PropertyGroup Label="Globals">
    <CustomProjectExtensionsPath>$(LocalAppData)\CustomProjectSystems\DnnVsProjectSystem\</CustomProjectExtensionsPath>
  </PropertyGroup>
  <Import Project="$(CustomProjectExtensionsPath)DnnVsProjectSystem.props" />

  <PropertyGroup>
    <OutputType>Library</OutputType>
    <TargetFramework>net45</TargetFramework>
    <OutputPath>bin\$(Configuration)</OutputPath>
    <RootNamespace>$safeprojectname$</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <None Include="**\*.txt" />
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="obj\**" />
    <EmbeddedResource Remove="obj\**" />
    <None Remove="obj\**" />
  </ItemGroup>


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

When I create an instance of my project (running under experimental vs instance) - nuget works great, and package references work in that if I add a nuget package I can see the package reference added to the project file, and I can see the reference listed in solution explorer.

However, when editing a csharp file, the assembly that has been added via Nuget cannot be resolved by Roslyn. I assume I am missing some XAML rules?

Please can you document / describe, what is needed to fully support package references, from a brand new project type.

i.e

  1. What XAML rules are needed?
  2. What capabilities are needed?
  3. What ms build targets / props are needed? (I,e is Project Sdk="Microsoft.NET.Sdk" enough?)

Thank you.

@jainaashish
Copy link
Contributor

When you're CPS and also declare TargetFramework property <TargetFramework>net45</TargetFramework> then NuGet treat it as .net core based project which means it waits for the nomination from project system in order to do restore for the packages which you might not be doing. So even though you added packages via PackageReference but they are never restored or added into project itself. You can also confirm it by running a solution restore explicitly which will fail in this case or going into /obj folder and look for project.assets.json file, it won't b there or missing those package references.

So I will suggest instead of going into CPS packageReference with nomination structure which is much more complicated further. You can fall into CPS packageReference legacy csproj type which is essentially without TargetFramework and TargetFrameworks properties (since for time being, NuGet uses these properties to differentiate between PackageReference .net core and PackageReference legacy) and you should be able to use PackageReference as a way to manage your package dependencies.

@dazinator
Copy link
Author

Thanks @jainaashish - I figured out the issue in the end, and I raised this: dotnet/sdk#1051

I'll close this issue.

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

No branches or pull requests

2 participants