public void DedupeReferencesFromPackages()
        {
            var project = new Project
            {
                AssemblyReferences = new List <AssemblyReference>
                {
                    new AssemblyReference {
                        Include  = "Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL",
                        HintPath = @"..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll"
                    },
                    new AssemblyReference {
                        Include = "System.Data.DataSetExtensions"
                    },
                    new AssemblyReference {
                        Include  = "Owin",
                        HintPath = @"..\packages\Owin.1.0\lib\net40\Owin.dll"
                    }
                },
                PackageReferences = new[]
                {
                    new PackageReference {
                        Id      = "Newtonsoft.Json",
                        Version = "1.0.0"
                    }
                },
                FilePath = new FileInfo(@".\dummy.csproj")
            };

            var transformation = new RemovePackageAssemblyReferencesTransformation();

            transformation.Transform(project);

            Assert.AreEqual(2, project.AssemblyReferences.Count);
        }
        public void HandlesNoPackagesConfig()
        {
            var project = new Project();

            var transformation = new RemovePackageAssemblyReferencesTransformation();

            transformation.Transform(project);
        }
        public void HandlesNoPackagesConfig()
        {
            var project = new Project2015To2017.Definition.Project();

            var transformation = new RemovePackageAssemblyReferencesTransformation();

            transformation.TransformAsync(null, null, project);
        }
Example #4
0
        public void HandlesNoPackagesConfig()
        {
            var project = new Project();

            var progress = new Progress <string>(x => { });

            var transformation = new RemovePackageAssemblyReferencesTransformation();

            transformation.Transform(project, progress);
        }
        public void DedupeReferencesFromPackagesAlternativePackagesFolder()
        {
            var projFile = @"TestFiles\AltNugetConfig\ProjectFolder\net46console.testcsproj";

            var project = new ProjectReader().Read(projFile);

            var transformation = new RemovePackageAssemblyReferencesTransformation();

            //Then attempt to clear any referencing the nuget packages folder
            transformation.Transform(project);

            //The only one left which points to another folder
            Assert.AreEqual(1, project.AssemblyReferences.Count);
            Assert.IsTrue(project.AssemblyReferences[0].Include.StartsWith("Owin"));
        }
        public async Task DedupeReferencesFromPackagesAlternativePackagesFolderAsync()
        {
            var project        = new Project();
            var transformation = new RemovePackageAssemblyReferencesTransformation();

            var projFile   = @"TestFiles\AltNugetConfig\ProjectFolder\net46console.testcsproj";
            var projFolder = new FileInfo(projFile).Directory;

            var doc = XDocument.Load(projFile);

            //First load information about the references and package references
            await new AssemblyReferenceTransformation().TransformAsync(doc, projFolder, project).ConfigureAwait(false);
            await new PackageReferenceTransformation().TransformAsync(doc, projFolder, project).ConfigureAwait(false);

            //Then attempt to clear any referencing the nuget packages folder
            await transformation.TransformAsync(doc, projFolder, project).ConfigureAwait(false);

            //The only one left which points to another folder
            Assert.AreEqual(1, project.AssemblyReferences.Count);
            Assert.IsTrue(project.AssemblyReferences[0].Include.StartsWith("Owin"));
        }
Example #7
0
        public void DedupeReferencesFromPackages()
        {
            var project = new Project
            {
                AssemblyReferences = new List <AssemblyReference>
                {
                    new AssemblyReference
                    {
                        Include  = "Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL",
                        HintPath = @"..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll"
                    },
                    new AssemblyReference
                    {
                        Include = "System.Data.DataSetExtensions"
                    },
                    new AssemblyReference
                    {
                        Include  = "Owin",
                        HintPath = @"..\packages\Owin.1.0\lib\net40\Owin.dll"
                    }
                },
                PackageReferences = new[]
                {
                    new PackageReference
                    {
                        Id = "Newtonsoft.Json"
                    }
                }
            };

            var transformation = new RemovePackageAssemblyReferencesTransformation();

            var projectFolder = new DirectoryInfo(".");

            var progress = new Progress <string>(x => { });

            transformation.TransformAsync(null, projectFolder, project, progress);

            Assert.AreEqual(2, project.AssemblyReferences.Count);
        }