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

'Build' target (and .nuget.g.props) not included in binlog? #169

Open
japj opened this issue May 23, 2022 · 0 comments
Open

'Build' target (and .nuget.g.props) not included in binlog? #169

japj opened this issue May 23, 2022 · 0 comments

Comments

@japj
Copy link

japj commented May 23, 2022

Hi again,

I am seeing some weirdness with package restore and binlog files (causing me some confusion when analyzing a totally different issue).

I made a testcase (based of an example in RepositoryTests.cs)

Basically this example is trying to:

  • confirm that PackageReference is actually consumed during a build
  • make a binlog of the whole process so I can do an analysis of what MSBuild is doing

However, the resulting binlog only shows the "Restore" target in the binlog, whereas I would also have expected a "Build" target in the binlog.

image

Also searching for PkgPackageA in the binlog does not get any hits, even though the ClassLibraryA.csproj.nuget.g.props contains it on disk.

This is tested with:

  • VS2022 17.0.6
  • MSBuildProjectCreator main branch

Note: in order to inspect the binlog file, you need to set a breakpoint to prevent automatic cleanup of the temp folder.

[Fact]
public void BuildCanConsumePackageWithGeneratePathProperty()
{
    string binLogPath = Path.Combine(TestRootPath, "test.binlog");

    using (PackageRepository.Create(TestRootPath)
            .Package("PackageB", "1.0", out Package packageB)
                .Library(TargetFramework)
            .Package("PackageA", "1.0.0", out Package packageA)
                .Dependency(packageB, TargetFramework)
                .Library(TargetFramework))
    {
        using (ProjectCollection projectCollection = new ProjectCollection())
        {
            projectCollection.RegisterLogger(new BinaryLogger
            {
                Parameters = $"LogFile={binLogPath}",
            });

            ProjectCreator.Templates.SdkCsproj(
                    path: Path.Combine(TestRootPath, "ClassLibraryA", "ClassLibraryA.csproj"),
                    targetFramework: TargetFramework,
                    projectCollection: projectCollection)
                .ItemPackageReference(packageA, metadata: new Dictionary<string, string>
                {
                    { "GeneratePathProperty", "true" },
                })
                .TryBuild(restore: true, out bool result, out BuildOutput buildOutput)
                .TryGetPropertyValue("PkgPackageA", out string packagePath);

            result.ShouldBeTrue(buildOutput.GetConsoleLog());
            packagePath.ShouldNotBeEmpty();
        }

        // NOTE: binlog does not look correct and seems to be missing actual content for PkgPackageA 
    }
}
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

1 participant