コード例 #1
0
        void ProcessAndCopyProject(string source, string destination)
        {
            var project = ProjectProcessor.Export(source, config, sample, destination);

            remainingProjects.UnionWith(project.FindImportedProjectsThatNeedExporting());

            if (project.ReferencesWin2DNuGetPackage)
            {
                switch (project.NuGetType)
                {
                case NuGetProjectType.PackagesConfig:
                    CopyPackagesConfigWithAddedWin2DReference(project);
                    break;

                case NuGetProjectType.Csproj:
                    // nothing - .csproj <PackageReference> doesn't require any external files
                    break;

                default:
                    throw new Exception(string.Format("Unhandled NuGetProjectType: {0}", project.NuGetType));
                }
            }

            // Any referenced files should be copied
            CopyReferencedFiles(project);
        }
コード例 #2
0
        void CopyProjectJsonWithAddedWin2DReference(ProjectProcessor project)
        {
            var source      = Path.Combine(project.SourceDirectory, "project.json");
            var destination = Path.Combine(project.DestinationDirectory, "project.json");

            if (!File.Exists(source))
            {
                // We're not going to try and create new ones of these from scratch; we'll just
                // update the existing one.
                throw new Exception(string.Format("Could not find existing {0}", source));
            }

            using (var reader = File.OpenText(source))
            {
                var projectJson = JObject.Load(new JsonTextReader(reader));
                projectJson["dependencies"].Children().Last().AddAfterSelf(
                    new JProperty(project.Win2DPackage, config.Options.Win2DVersion));

                using (var writer = File.CreateText(destination))
                {
                    var jsonWriter = new JsonTextWriter(writer)
                    {
                        Formatting = Formatting.Indented
                    };

                    projectJson.WriteTo(jsonWriter);
                    copiedFiles.Add(destination);
                }
            }
        }
コード例 #3
0
        void ProcessAndCopyProject(string source, string destination, bool isSingletonProject)
        {
            var project = ProjectProcessor.Export(source, isSingletonProject, config, sample, destination);

            remainingProjects.UnionWith(project.FindImportedProjectsThatNeedExporting());

            if (project.ReferencesWin2DNuGetPackage)
            {
                switch (project.NuGetType)
                {
                case NuGetProjectType.PackagesConfig:
                    CopyPackagesConfigWithAddedWin2DReference(project);
                    break;

                case NuGetProjectType.ProjectJson:
                    CopyProjectJsonWithAddedWin2DReference(project);
                    break;

                default:
                    throw new Exception(string.Format("Unhandled NuGetProjectType: {0}", project.NuGetType));
                }
            }

            // Any referenced files should be copied
            CopyReferencedFiles(project);
        }
コード例 #4
0
ファイル: ProjectProcessor.cs プロジェクト: fengweijp/Win2D
 public static ProjectProcessor Export(string projectFileName, bool isSingletonProject, Configuration config, SampleDirectory sample, string destination)
 {
     var project = new ProjectProcessor(projectFileName, isSingletonProject, config, sample);
     project.Process();
     project.Save(destination);
     return project;
 }
コード例 #5
0
        public static ProjectProcessor Export(string projectFileName, Configuration config, SampleDirectory sample, string destination)
        {
            var project = new ProjectProcessor(projectFileName, config, sample);

            project.Process();
            project.Save(destination);
            return(project);
        }
コード例 #6
0
        void CopyPackagesConfigWithAddedWin2DReference(ProjectProcessor project)
        {
            var source = Path.Combine(project.SourceDirectory, "packages.config");

            XDocument packagesConfig;

            if (File.Exists(source))
            {
                packagesConfig = XDocument.Load(source);
            }
            else
            {
                packagesConfig = new XDocument();
                packagesConfig.Add(new XElement("packages"));
            }

            RemoveExistingWin2DReferences(packagesConfig);

            var package = new XElement("package");

            package.SetAttributeValue("id", project.Win2DPackage);
            package.SetAttributeValue("version", config.Options.Win2DVersion);

            // The framework name in packages.config does not exactly match then name on disk
            string framework;

            if (project.IsNative)
            {
                framework = "Native";
            }
            else
            {
                switch (project.GetTargetPlatformIdentifier())
                {
                case TargetPlatformIdentifier.Windows:
                    framework = "win81";
                    break;

                case TargetPlatformIdentifier.WindowsPhone:
                    framework = "wpa81";
                    break;

                default:
                    throw new Exception(string.Format("Unexpected TargetPlatformIdentifier", project.GetTargetPlatformIdentifier()));
                }
            }

            package.SetAttributeValue("targetFramework", framework);

            packagesConfig.Root.Add(package);

            var destination = Path.Combine(project.DestinationDirectory, "packages.config");

            packagesConfig.Save(destination);
            copiedFiles.Add(destination);
        }
コード例 #7
0
ファイル: SampleExporter.cs プロジェクト: NathanAUS/Win2D
        void CopyPackagesConfigWithAddedWin2DReference(ProjectProcessor project)
        {
            var source = Path.Combine(project.SourceDirectory, "packages.config");

            XDocument packagesConfig;

            if (File.Exists(source))
            {
                packagesConfig = XDocument.Load(source);
            }
            else
            {
                packagesConfig = new XDocument();
                packagesConfig.Add(new XElement("packages"));
            }

            RemoveExistingWin2DReferences(packagesConfig);

            var package = new XElement("package");
            package.SetAttributeValue("id", project.Win2DPackage);
            package.SetAttributeValue("version", config.Options.Win2DVersion);

            // The framework name in packages.config does not exactly match then name on disk
            string framework;
            if (project.IsNative)
            {
                framework = "Native";
            }
            else
            {
                switch (project.GetTargetPlatformIdentifier())
                {
                    case TargetPlatformIdentifier.Windows:
                        framework = "win81";
                        break;

                    case TargetPlatformIdentifier.WindowsPhone:
                        framework = "wpa81";
                        break;

                    default:
                        throw new Exception(string.Format("Unexpected TargetPlatformIdentifier", project.GetTargetPlatformIdentifier()));
                }
            }

            package.SetAttributeValue("targetFramework", framework);

            packagesConfig.Root.Add(package);

            var destination = Path.Combine(project.DestinationDirectory, "packages.config");
            packagesConfig.Save(destination);
            copiedFiles.Add(destination);
        }
コード例 #8
0
        void CopyReferencedFiles(ProjectProcessor project)
        {
            foreach (var srcDst in project.FilesToCopy)
            {
                var source      = srcDst.Key;
                var destination = srcDst.Value;

                if (!copiedFiles.Contains(destination))
                {
                    CopyFile(source, destination);
                    copiedFiles.Add(destination);
                }
            }
        }
コード例 #9
0
ファイル: SampleExporter.cs プロジェクト: markmnl/Win2D
        void ProcessAndCopyProject(string source, string destination)
        {
            var project = ProjectProcessor.Export(source, config, sample, destination);

            remainingProjects.UnionWith(project.FindImportedProjectsThatNeedExporting());

            if (project.ReferencesWin2DNuGetPackage)
            {
                CopyPackagesConfigWithAddedWin2DReference(project);
            }

            // Any referenced files should be copied
            CopyReferencedFiles(project);
        }
コード例 #10
0
ファイル: SampleExporter.cs プロジェクト: NathanAUS/Win2D
        void CopyReferencedFiles(ProjectProcessor project)
        {
            foreach (var srcDst in project.FilesToCopy)
            {
                var source = srcDst.Key;
                var destination = srcDst.Value;

                if (!copiedFiles.Contains(destination))
                {
                    CopyFile(source, destination);
                    copiedFiles.Add(destination);
                }
            }
        }
コード例 #11
0
ファイル: SampleExporter.cs プロジェクト: NathanAUS/Win2D
        void CopyProjectJsonWithAddedWin2DReference(ProjectProcessor project)
        {
            var source = Path.Combine(project.SourceDirectory, "project.json");
            var destination = Path.Combine(project.DestinationDirectory, "project.json");

            if (!File.Exists(source))
            {
                // We're not going to try and create new ones of these from scratch; we'll just
                // update the existing one.
                throw new Exception(string.Format("Could not find existing {0}", source));
            }

            using (var reader = File.OpenText(source))
            {
                var projectJson = JObject.Load(new JsonTextReader(reader));
                projectJson["dependencies"].Children().Last().AddAfterSelf(
                    new JProperty(project.Win2DPackage, config.Options.Win2DVersion));

                using (var writer = File.CreateText(destination))
                {
                    var jsonWriter = new JsonTextWriter(writer)
                    {
                        Formatting = Formatting.Indented
                    };

                    projectJson.WriteTo(jsonWriter);
                    copiedFiles.Add(destination);
                }
            }
        }