Esempio n. 1
0
        public void DotnetRestore_WithAuthorSignedPackage_Succeeds()
        {
            using (var packageSourceDirectory = TestDirectory.Create())
                using (var testDirectory = TestDirectory.Create())
                {
                    var packageFile = new FileInfo(Path.Combine(packageSourceDirectory.Path, "TestPackage.AuthorSigned.1.0.0.nupkg"));
                    var package     = GetResource(packageFile.Name);

                    File.WriteAllBytes(packageFile.FullName, package);

                    var projectName      = "ClassLibrary1";
                    var workingDirectory = Path.Combine(testDirectory, projectName);
                    var projectFile      = Path.Combine(workingDirectory, $"{projectName}.csproj");

                    _msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");

                    using (var stream = File.Open(projectFile, FileMode.Open, FileAccess.ReadWrite))
                    {
                        var xml = XDocument.Load(stream);

                        ProjectFileUtils.SetTargetFrameworkForProject(xml, "TargetFrameworks", "netstandard1.3");

                        var attributes = new Dictionary <string, string>()
                        {
                            { "Version", "1.0.0" }
                        };

                        ProjectFileUtils.AddItem(
                            xml,
                            "PackageReference",
                            "TestPackage.AuthorSigned",
                            "netstandard1.3",
                            new Dictionary <string, string>(),
                            attributes);

                        ProjectFileUtils.WriteXmlToFile(xml, stream);
                    }

                    var args = $"--source \"{packageSourceDirectory.Path}\" ";

                    _msbuildFixture.RestoreProject(workingDirectory, projectName, args);
                }
        }
Esempio n. 2
0
        public void DotnetRestore_WithAuthorSignedPackage_Succeeds()
        {
            using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext())
            {
                var packageFile = new FileInfo(Path.Combine(pathContext.PackageSource, "TestPackage.AuthorSigned.1.0.0.nupkg"));
                var package     = GetResource(packageFile.Name);

                File.WriteAllBytes(packageFile.FullName, package);

                var projectName      = "ClassLibrary1";
                var workingDirectory = Path.Combine(pathContext.SolutionRoot, projectName);
                var projectFile      = Path.Combine(workingDirectory, $"{projectName}.csproj");

                _msbuildFixture.CreateDotnetNewProject(pathContext.SolutionRoot, projectName, "classlib -f netstandard2.0");

                using (var stream = File.Open(projectFile, FileMode.Open, FileAccess.ReadWrite))
                {
                    var xml = XDocument.Load(stream);

                    var attributes = new Dictionary <string, string>()
                    {
                        { "Version", "1.0.0" }
                    };

                    ProjectFileUtils.AddItem(
                        xml,
                        "PackageReference",
                        "TestPackage.AuthorSigned",
                        string.Empty,
                        new Dictionary <string, string>(),
                        attributes);

                    ProjectFileUtils.WriteXmlToFile(xml, stream);
                }

                _msbuildFixture.RestoreProject(workingDirectory, projectName, args: string.Empty);
            }
        }