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

Private is missing from ProjectReference #1794

Closed
scemino opened this issue Sep 12, 2017 · 5 comments · Fixed by #3571
Closed

Private is missing from ProjectReference #1794

scemino opened this issue Sep 12, 2017 · 5 comments · Fixed by #3571
Assignees
Milestone

Comments

@scemino
Copy link

scemino commented Sep 12, 2017

When I parse a project, some properties are missing in the references of the project.

What You Are Seeing?

In the ProjectReference object, I have theses properties:

  • FilePath FilePath
  • string Name
  • FilePath Package
  • string Project

What is Expected?

I should have also the property Private (also present in ProjectAssemblyReference)

What version of Cake are you using?

Version 0.19.3+Branch.main.Sha.c8a44d4c031e5c9631ec3044536c6af70f3fb04f

Are you running on a 32 or 64 bit system?

64 bit

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

Sets Copy local to false or true to a project of your solution.
Then create a build.cake file with:

var parsedProject = ParseProject("<your project path here>");
foreach(var prjRef in parsedProject.ProjectReferences){
    prjRef.Dump();
}
@ptvbnk
Copy link
Contributor

ptvbnk commented Jul 4, 2021

@augustoproiete

I am not sure how to recreate this scenario.

Sets Copy local to false or true to a project of your solution.

How to set this? I couldn't find this copy local variable on project/solution.

var parsedProject = ParseProject("<your project path here>");
foreach(var prjRef in parsedProject.ProjectReferences){
    prjRef.Dump();
}

Just with above code in cake file I am getting a different error.

Tool 'cake.tool' (version '1.1.0') was restored. Available commands: dotnet-cake

Restore was successful.
C:/CodeContribute/exampleapp/build.cake(3,12): error CS1061: 'ProjectReference' does not contain a definition for 'Dump' and no accessible extension method 'Dump' accepting a first argument of type 'ProjectReference' could be found (are you missing a using directive or an assembly reference?)
Error: Error(s) occurred when compiling build script:
C:/CodeContribute/exampleapp/build.cake(3,12): error CS1061: 'ProjectReference' does not contain a definition for 'Dump' and no accessible extension method 'Dump' accepting a first argument of type 'ProjectReference' could be found (are you missing a using directive or an assembly reference?)

@augustoproiete
Copy link
Member

@coder2213 The Dump method was an extension method that @scemino had available in his Cake script at the time and is not something that exists in Cake, so just remove this call and inspect the properties of the ProjectReference class instead.

The point @scemino is making is that the ProjectReference class is missing a property called Private which is a valid property in an MSBuild project file and is similar to a property with the same name in the ProjectAssemblyReference class.

Here is an example of a .csproj file that has both an assembly reference and a project reference with the Private property set:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System.Xml">
      <Private>True</Private>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\TestRefProject\TestRefProject.csproj">
      <Project>{45a6bfcc-deaa-4b83-b941-cb9db2bf658b}</Project>
      <Name>TestRefProject</Name>
      <Private>False</Private>
    </ProjectReference>
  </ItemGroup>
</Project>

And here's a Cake script that reproduces what @scemino explained:

var parsedProject = ParseProject("./ReproCake1794.csproj");

foreach (var asmRef in parsedProject.References)
{
    Information("Assembly ref: Include={0}, Private={1}", asmRef.Include, asmRef.Private);
}

foreach (var projRef in parsedProject.ProjectReferences)
{
    Information("Project ref: Name={0}, Private={1}", projRef.Name, projRef.Private);
}

This script does not compile because ProjectReferences don't have a Private property (but should).

@franciscomoloureiro
Copy link
Contributor

Hello, I have this issue fixed on my local uncommited changes.
Can I fork and create a pull request?

@augustoproiete
Copy link
Member

@franciscomoloureiro Sure. Just make sure you add the corresponding unit test(s)

@cake-build-bot
Copy link

🎉 This issue has been resolved in version v2.0.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

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

Successfully merging a pull request may close this issue.

5 participants