private void AddReferenceToLibrary(XDocument project, ReferenceScenario scenario)
        {
            var ns        = project.Root.Name.Namespace;
            var itemGroup = project.Root
                            .Elements(ns + "ItemGroup")
                            .Where(ig => ig.Elements(ns + "Reference").Any())
                            .FirstOrDefault();

            if (itemGroup == null)
            {
                itemGroup = new XElement(ns + "ItemGroup");
                project.Root.Add(itemGroup);
            }

            if (scenario == ReferenceScenario.ProjectReference)
            {
                itemGroup.Add(new XElement(ns + "ProjectReference",
                                           new XAttribute("Include", $@"..\{LibraryName}\{LibraryName}.csproj")));
            }
            else
            {
                var binaryPath = $@"..\{LibraryName}\bin\$(Configuration)\netstandard2.0\{LibraryName}.dll";
                if (scenario == ReferenceScenario.HintPath)
                {
                    itemGroup.Add(new XElement(ns + "Reference",
                                               new XAttribute("Include", LibraryName),
                                               new XElement(ns + "HintPath", binaryPath)));
                }
                else if (scenario == ReferenceScenario.RawFileName)
                {
                    itemGroup.Add(new XElement(ns + "Reference",
                                               new XAttribute("Include", binaryPath)));
                }
            }
        }
        public void It_includes_netstandard(bool isSdk, ReferenceScenario scenario)
        {
            var testAsset = _testAssetsManager
                            .CopyTestAsset(GetTemplateName(isSdk), identifier: scenario.ToString())
                            .WithSource()
                            .WithProjectChanges((projectPath, project) =>
            {
                if (IsAppProject(projectPath))
                {
                    AddReferenceToLibrary(project, scenario);
                }
            });

            if (scenario != ReferenceScenario.ProjectReference)
            {
                testAsset.Restore(Log, relativePath: LibraryName);

                var libBuildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, LibraryName));
                libBuildCommand
                .Execute()
                .Should()
                .Pass();
            }

            testAsset.Restore(Log, relativePath: AppName);

            var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, AppName));

            buildCommand
            .Execute()
            .Should()
            .Pass();

            var outputDirectory = isSdk ?
                                  buildCommand.GetOutputDirectory("net461") :
                                  buildCommand.GetNonSDKOutputDirectory();

            outputDirectory.Should().HaveFiles(new[] {
                "netstandard.dll",
                $"{AppName}.exe.config"
            });
        }