Exemplo n.º 1
0
        ProjectProcessor(string projectFileName, Configuration config, SampleDirectory sample)
        {
            this.fileName = projectFileName;
            this.SourceDirectory = Path.GetDirectoryName(fileName);
            this.DestinationDirectory = config.GetDestination(SourceDirectory);
            this.config = config;
            this.sample = sample;

            var relativeSolutionDirectory = GetRelativePath(sample.Destination + "\\", DestinationDirectory);
            this.relativePackagesDirectory = Path.Combine(relativeSolutionDirectory, "packages\\");

            doc = XDocument.Load(projectFileName);

            this.IsNative = fileName.EndsWith("vcxproj");
            this.ReferencesWin2DNuGetPackage = FindAndRemoveWin2DProjectReferences();

            bool isUap = (GetTargetPlatformIdentifier() == TargetPlatformIdentifier.UAP);

            if (isUap && !this.IsNative)
                this.NuGetType = NuGetProjectType.ProjectJson;
            else
                this.NuGetType = NuGetProjectType.PackagesConfig;

            if (isUap)
                Win2DPackage = "Win2D.uwp";
            else
                Win2DPackage = "Win2D.win81";
        }
Exemplo n.º 2
0
        string ProcessFileReference(string originalValue)
        {
            string includedFile = originalValue;

            // If this is a reference in a Shared project then it'll start with $(MSBuildThisFileDirectory).
            // Strip this off while we're looking at this.
            if (includedFile.StartsWith(MSBuildThisFileDirectory))
            {
                includedFile = includedFile.Substring(MSBuildThisFileDirectory.Length);
            }

            // Expand properties (eg $(AssetDir))
            includedFile = Expand(includedFile);

            // Ignore anything that isn't a valid path name
            if (!IsValidPathName(includedFile))
            {
                return(originalValue);
            }

            // Ignore anything that doesn't exist
            var fullPath = Path.GetFullPath(Path.Combine(SourceDirectory, includedFile));

            if (!File.Exists(fullPath))
            {
                return(originalValue);
            }

            // If the file is part of this sample then we can reference it unmodified
            if (fullPath.StartsWith(sample.Source))
            {
                var dest = config.GetDestination(fullPath);
                FilesToCopy.Add(fullPath, dest);
                return(originalValue);
            }

            // Otherwise we'll need to copy it somewhere to reference it, and update our element to point to the new location
            foreach (var entry in config.DuplicateFiles)
            {
                if (fullPath.StartsWith(entry.Key))
                {
                    var value = entry.Value;

                    // If there is only one variant of this project (eg. CompositionExample, which only targets UAP)
                    // then redirect files that would normally go in the Shared folder to the main project directory.
                    if (isSingletonProject)
                    {
                        value = value.Replace("Shared", "$(ProjectDir)");
                    }

                    var dest = Path.GetFullPath(fullPath.Replace(entry.Key, Path.Combine(sample.Destination, Expand(value))));
                    FilesToCopy[fullPath] = dest;

                    return(GetRelativePath(dest, DestinationDirectory));
                }
            }

            return(originalValue);
        }
Exemplo n.º 3
0
        ProjectProcessor(string projectFileName, Configuration config, SampleDirectory sample)
        {
            this.fileName = projectFileName;
            this.SourceDirectory = Path.GetDirectoryName(fileName);
            this.DestinationDirectory = config.GetDestination(SourceDirectory);
            this.config = config;
            this.sample = sample;

            var relativeSolutionDirectory = GetRelativePath(sample.Destination + "\\", DestinationDirectory);
            this.relativePackagesDirectory = Path.Combine(relativeSolutionDirectory, "packages\\");

            doc = XDocument.Load(projectFileName);
        }
Exemplo n.º 4
0
        void ExportSampleProjects()
        {
            // Process all the projects.  Any files referenced by a project will be exported.
            var projects = FindProjects();

            remainingProjects = new HashSet <string>(from project in projects select project.FullName);
            copiedFiles       = new HashSet <string>();

            while (remainingProjects.Count > 0)
            {
                var project     = remainingProjects.First();
                var destination = config.GetDestination(project);

                if (!copiedFiles.Contains(destination) && File.Exists(project))
                {
                    ExportProject(project, destination);
                    copiedFiles.Add(destination);
                }

                remainingProjects.Remove(project);
            }
        }
Exemplo n.º 5
0
        ProjectProcessor(string projectFileName, Configuration config, SampleDirectory sample)
        {
            this.fileName             = projectFileName;
            this.SourceDirectory      = Path.GetDirectoryName(fileName);
            this.DestinationDirectory = config.GetDestination(SourceDirectory);
            this.config = config;
            this.sample = sample;

            var relativeSolutionDirectory = GetRelativePath(sample.Destination + "\\", DestinationDirectory);

            this.relativePackagesDirectory = Path.Combine(relativeSolutionDirectory, "packages\\");

            doc = XDocument.Load(projectFileName);
        }
Exemplo n.º 6
0
        ProjectProcessor(string projectFileName, bool isSingletonProject, Configuration config, SampleDirectory sample)
        {
            this.fileName             = projectFileName;
            this.SourceDirectory      = Path.GetDirectoryName(fileName);
            this.DestinationDirectory = config.GetDestination(SourceDirectory);
            this.isSingletonProject   = isSingletonProject;
            this.config = config;
            this.sample = sample;

            var relativeSolutionDirectory = GetRelativePath(sample.Destination + "\\", DestinationDirectory);

            this.relativePackagesDirectory = Path.Combine(relativeSolutionDirectory, "packages\\");

            doc = XDocument.Load(projectFileName);

            this.IsNative = fileName.EndsWith("vcxproj");
            this.ReferencesWin2DNuGetPackage = FindAndRemoveWin2DProjectReferences();

            bool isUap = (GetTargetPlatformIdentifier() == TargetPlatformIdentifier.UAP);

            if (isUap && !this.IsNative)
            {
                this.NuGetType = NuGetProjectType.ProjectJson;
            }
            else
            {
                this.NuGetType = NuGetProjectType.PackagesConfig;
            }

            if (isUap)
            {
                Win2DPackage = "Win2D.uwp";
            }
            else
            {
                Win2DPackage = "Win2D.win81";
            }
        }