Ejemplo n.º 1
0
        public virtual Task AddReferenceAsync(string referencePath)
        {
            string fullPath     = PathUtility.GetAbsolutePath(ProjectFullPath, referencePath);
            string relativePath = PathUtility.GetRelativePath(ProjectFileFullPath, fullPath);

            string assemblyFileName = Path.GetFileNameWithoutExtension(fullPath);

            try
            {
                var assemblyName = AssemblyName.GetAssemblyName(fullPath);
                assemblyFileName = assemblyName.FullName;
            }
            catch
            {
                // no-op
            }

            MsBuildProject.AddItem(
                "Reference",
                assemblyFileName,
                new KeyValuePair <string, string>[] {
                new KeyValuePair <string, string>("HintPath", relativePath),
                new KeyValuePair <string, string>("Private", "True")
            });

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public override void AddProjectToSolution(string projectFullPath)
        {
            var msbuildProj  = MsBuildProject.Load(projectFullPath);
            var solutionFile = MSBuildSolution.Create(SolutionPath);

            solutionFile.AddProjectToSolution(msbuildProj.Name, msbuildProj.Guid);
        }
Ejemplo n.º 3
0
        static bool ConvertProject(string pathToProject)
        {
            var  xmlProject = MsBuildProject.Load(pathToProject);
            bool ok         = (xmlProject != null);

            if (ok)
            {
                ok = xmlProject.AddQtMsBuildReferences();
            }
            if (ok)
            {
                ok = xmlProject.ConvertCustomBuildToQtMsBuild();
            }
            if (ok)
            {
                ok = xmlProject.EnableMultiProcessorCompilation();
            }
            if (ok)
            {
                ok = xmlProject.UpdateProjectFormatVersion();
            }
            if (ok)
            {
                ok = xmlProject.Save();
            }

            // Initialize Qt variables
            if (ok)
            {
                xmlProject.BuildTarget("QtVarsDesignTime");
            }
            return(ok);
        }
Ejemplo n.º 4
0
        public Project(StructEx.Solution solution, string title, string fileName) : base(solution, title, fileName)
        {
            Files          = new List <File>();
            ProjectContent = new CSharpProjectContent();
            ResolvedReferencedAssemblies = new List <IUnresolvedAssembly>();

            ProjectContent = ProjectContent.SetAssemblyName(AssemblyName);
            ProjectContent = ProjectContent.SetProjectFileName(fileName);

            ProjectContent = ProjectContent.SetCompilerSettings(Utils.Convert.ToCompilerSettings(CompilerSettings));

            foreach (var sourceCodeFile in MsBuildProject.GetItems("Compile"))
            {
                Files.Add(new File(this, Path.Combine(MsBuildProject.DirectoryPath, sourceCodeFile.EvaluatedInclude)));
            }

            var files =
                Files.Select(f => f.UnresolvedTypeSystemForFile);

            ProjectContent = ProjectContent.AddOrUpdateFiles(files);

            foreach (var projectReference in ReferencedProjects)
            {
                ProjectContent = ProjectContent.AddAssemblyReferences(new[] { new ProjectReference(projectReference) });
            }

            ResolveAssemblies();
        }
Ejemplo n.º 5
0
        public override void AddItems(params string[] itemsFullPath)
        {
            if (itemsFullPath == null || itemsFullPath.Length == 0)
            {
                return;
            }

            var projectFileName = FindProject(GenContext.Current.OutputPath);

            if (string.IsNullOrEmpty(projectFileName))
            {
                throw new Exception($"There is not project file in {GenContext.Current.OutputPath}");
            }

            var msbuildProj = MsBuildProject.Load(projectFileName);

            if (msbuildProj != null)
            {
                foreach (var item in itemsFullPath)
                {
                    msbuildProj.AddItem(item);
                }

                msbuildProj.Save();
            }
        }
Ejemplo n.º 6
0
        public AuditProject(IProject roslynProject, FrameworkName targetFramework, Options options)
        {
            // Shared
            RoslynProject    = roslynProject;
            MsBuildProject   = RoslynProject.GetMsBuildProject();
            LocalRepository  = RoslynProject.Solution.GetLocalPackageRepository();
            ConfigReferences = PackageReferenceFile.CreateFromProject(RoslynProject.FilePath).GetPackageReferences(false).ToList();
            CsprojReferences = MsBuildProject.GetDirectPackageAssemblies().Select(g => g.Key).Where(r => r != null).Distinct().ToList();
            References       = ConfigReferences.Union(CsprojReferences).ToList();
            Packages         = options.Unused || options.Snapshot || options.Missing || options.Project
                ? References.Select(r => r.GetPackage(LocalRepository)).Where(p => p != null).ToList()
                : Enumerable.Empty <IPackage>();
            // Unused Packages
            UnusedPackages = options.Unused
                ? GetUnusedPackages(targetFramework, options.UnusedUsings)
                : Enumerable.Empty <UnusedPackage>();

            // Snapshot References
            SnapshotPackages = options.Snapshot
                ? Packages.GetSnapshotPackages()
                : Enumerable.Empty <SnapshotPackage>();

            // Missing Packages
            MissingPackages = options.Missing
                ? GetMissingPackages(targetFramework)
                : Enumerable.Empty <MissingPackageDependency>();

            // Project Packages
            ProjectPackages = options.Project
                ? GetProjectPackages()
                : Enumerable.Empty <ProjectPackage>();

            // File Diff References
            MissingPackageReferences = options.FileDiff
                ? GetMissingPackageReferences()
                : Enumerable.Empty <InconsistentFiles>();

            // Duplicate Package References
            DuplicatePackageReferences = options.FileDiff
                ? GetDuplicatePackageReferences()
                : Enumerable.Empty <DuplicatePackageReference>();

            // Orphan Binding Redirects
            BindingRedirectOnlyReferences = options.FileDiff
                ? GetBindingRedirectOnlyReferences()
                : Enumerable.Empty <OrphanAssemblyBinding>();

            // Mismatched Binding Redirects
            BindingRedirectMismatchReferences = options.RedirectMismatch
                ? GetBindingRedirectMismatchReferences()
                : Enumerable.Empty <MismatchAssemblyBinding>();

            BadProjectRefGuids = options.FileDiff
                ? GetBadProjectRefGuids()
                : Enumerable.Empty <MismatchedGuid>();

            IllegalNugetTargets = options.NugetTargets
                ? GetIllegalNugetTargets()
                : Enumerable.Empty <IllegalProjectFileElement>();
        }
Ejemplo n.º 7
0
 void UpdataBuildConfigOfProject(MsBuildProject project)
 {
     project.BuildConfiguration = FBuildConfigIn[0];
     if (IsProjectInUse(project))
     {
         project.CompileAsync();
     }
 }
Ejemplo n.º 8
0
        private IEnumerable <OrphanOrMismatchAssemblyBinding> GetBindingRedirectMismatchReferences()
        {
            var allAssemblyIds = GetAllAssemblyReferences().SelectMany(p => p).ToDictionary(k => k.Key, v => v.Value);

            return(MsBuildProject.GetBindingRedirects()
                   .Where(br => !(allAssemblyIds.ContainsKey(br.Name) && allAssemblyIds[br.Name].Equals(br.NewVersion)))
                   .Select(br => new OrphanOrMismatchAssemblyBinding(br)));
        }
Ejemplo n.º 9
0
        private IEnumerable <MismatchedGuid> GetBadProjectRefGuids()
        {
            var solutionProjects = SolutionFile.FromFile(RoslynProject.Solution.FilePath).Projects;

            return(MsBuildProject.GetProjectReferences()
                   .Where(r => !r.EqualByGuid(GetSolutionProjectFromProjectReference(r, solutionProjects)))
                   .Select(r => new MismatchedGuid(r.GetProjectGuid(), r.GetProjectName(), "Project Reference")));
        }
Ejemplo n.º 10
0
        private IEnumerable <OrphanAssemblyBinding> GetBindingRedirectOnlyReferences()
        {
            var allAssemblyIds = GetAllAssemblyReferences().SelectMany(p => p).Select(k => k.Key).ToHashSet();

            return(MsBuildProject.GetBindingRedirects()
                   .Where(br => !allAssemblyIds.Contains(br.Name))
                   .Select(br => new OrphanAssemblyBinding(br)));
        }
Ejemplo n.º 11
0
        public virtual void RemoveImport(string targetFullPath)
        {
            if (targetFullPath == null)
            {
                throw new ArgumentNullException("targetFullPath");
            }

            MsBuildProject.RemoveImport(targetFullPath);
        }
Ejemplo n.º 12
0
        protected virtual void AddFileToProject(string path)
        {
            if (!ExcludeFile(path))
            {
                MsBuildProject.AddItem("Content", path);

                NuGetProjectContext.Log(MessageLevel.Debug, "AddedFileToProject", path, ProjectName);
            }
        }
Ejemplo n.º 13
0
        public virtual void AddImport(string targetFullPath, ImportLocation location)
        {
            if (targetFullPath == null)
            {
                throw new ArgumentNullException("targetFullPath");
            }

            MsBuildProject.AddImport(targetFullPath, location == ImportLocation.Top ? true : false);
        }
Ejemplo n.º 14
0
        private MsBuildProject OpenMsBuildProject(string filename)
        {
            var msBuildProject = MsBuildProject.Deserialize(filename, Terminal.HandleException);

            if (msBuildProject == null)
            {
                FileOpenFailed("MsBuild Project", filename);
            }
            return(msBuildProject);
        }
Ejemplo n.º 15
0
        public virtual IEnumerable <string> GetFullPaths(string fileName)
        {
            foreach (var projectItem in MsBuildProject.GetItems())
            {
                var itemFileName = Path.GetFileName(projectItem.EvaluatedInclude);

                if (string.Equals(fileName, itemFileName, StringComparison.OrdinalIgnoreCase))
                {
                    yield return(Path.Combine(ProjectFullPath, projectItem.EvaluatedInclude));
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Called by AbstractFileFactory to extract all node infos in given file.
        /// </summary>
        protected override IEnumerable <INodeInfo> LoadNodeInfos(string filename)
        {
            var nodeInfos = new List <INodeInfo>();

            // We can't handle dynamic plugins
            if (!MsBuildProject.IsDynamicAssembly(filename))
            {
                LoadNodeInfosFromFile(filename, filename, ref nodeInfos, true);
            }

            return(nodeInfos);
        }
Ejemplo n.º 17
0
        public override string GetActiveProjectGuid()
        {
            var projectFileName = FindProject(GenContext.Current.ProjectPath);

            if (string.IsNullOrEmpty(projectFileName))
            {
                throw new Exception($"There is not project file in {GenContext.Current.ProjectPath}");
            }

            var msbuildProj = MsBuildProject.Load(projectFileName);

            return(msbuildProj.Guid);
        }
Ejemplo n.º 18
0
        private IEnumerable <DuplicatePackageReference> GetDuplicatePackageReferences()
        {
            var configDuplicates = ConfigReferences
                                   .Duplicates()
                                   .Select(r => new DuplicatePackageReference(r, "packages.config"));

            var csprojDuplicates = MsBuildProject.GetDirectPackageAssemblies()
                                   .SelectMany(p => p, (grouping, s) => new { grouping, s })
                                   .DuplicatesBy(a => a.s)
                                   .Select(r => new DuplicatePackageReference(r.grouping.Key, ".csproj", r.s.Key));

            return(configDuplicates.Concat(csprojDuplicates));
        }
Ejemplo n.º 19
0
 private IEnumerable <MissingPackageDependency> GetMissingPackages(FrameworkName targetFramework)
 {
     // All dependencies of all packages ...
     return(Packages.SelectMany(p => p.GetCompatiblePackageDependencies(targetFramework),
                                (package, dependency) => new { package, dependency })
            // ... that aren't installed as a package ...
            .Where(d => !Packages.Select(p => p.Id).Contains(d.dependency.Id))
            // ... or as a project
            .Where(d => !MsBuildProject.GetProjectReferenceNames().Contains(d.dependency.Id))
            // Dependencies don't have good equality checking
            .GroupBy(d => d.dependency.ToString())
            .Select(g => new MissingPackageDependency(g.First().dependency, g.Select(d => d.package))));
 }
Ejemplo n.º 20
0
        public virtual Task RemoveReferenceAsync(string name)
        {
            name = Path.GetFileNameWithoutExtension(name);

            dynamic item = GetReference(name);

            if (item != null)
            {
                MsBuildProject.RemoveItem(item);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 21
0
        public virtual void RemoveFile(string path)
        {
            if (!string.IsNullOrEmpty(path))
            {
                var files = MsBuildProject.GetItemsByEvaluatedInclude(path);
                if (files != null)
                {
                    MsBuildProject.RemoveItems(files);
                    NuGetProjectContext.Log(MessageLevel.Debug, "RemovedFileToProject", path, ProjectName);
                }

                FileSystemUtility.DeleteFileAndParentDirectoriesIfEmpty(ProjectFullPath, path, NuGetProjectContext);
            }
        }
Ejemplo n.º 22
0
        public IReadOnlyDictionary <string, IEvaluatedProjectPropertyValue> EvaluateProperties(Dictionary <string, string> propertyValues = null)
        {
            var result = new Dictionary <string, IEvaluatedProjectPropertyValue>();

            using (new MsBuildConditionContext(MsBuildProject, propertyValues))
            {
                foreach (var property in Properties.Values)
                {
                    var projectPropertyElement = MsBuildProject.GetProperty(property.Name)?.Xml;
                    if (projectPropertyElement != null)
                    {
                        result.Add(
                            property.Name,
                            new EvaluatedProjectPropertyValue(projectPropertyElement.Value, new ProjectPropertyOccurrence(projectPropertyElement)));
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 23
0
        private IEnumerable <UnusedPackage> GetUnusedPackages(FrameworkName targetFramework, bool lookAtUnusedUsings)
        {
            var usedAssemblyPaths = RoslynProject.Documents
                                    .SelectMany(d => d.GetUsedAssemblies(lookAtUnusedUsings))
                                    .Select(a => a.Identity.Location)
                                    .Where(p => !string.IsNullOrEmpty(p))
                                    .Distinct().ToList();

            return(Packages
                   // Packages not referenced by other packages ...
                   .GetDirectPackages(targetFramework)
                   // ... that have assemblies ...
                   .Where(p => p.AssemblyReferences.Any())
                   // ... and the namespaces in those assemblies do not exist in the project ...
                   .Where(p => p.GetTypes().Select(t => t.FullName).Intersect(MsBuildProject.GetNamespaces()).IsEmpty())
                   // ... and the assemblies are not used by symbols in the project
                   .Where(p => !p.GetAssemblyPaths().Any(a => usedAssemblyPaths.Any(u => u.Contains(a))))
                   .Where(p => !p.Id.Equals("Aspose.Words")) // Roslyn seems to have a problem with this package
                   .Select(p => new UnusedPackage(p)));
        }
Ejemplo n.º 24
0
        public Result.IfSuccess <MsBuildProject> TryUpdateAsync(MsBuildProject msBuildProject, IEnumerable <PackageUpdate> packageUpdates)
        {
            var fileContent = msBuildProject.ProjectContent;
            var wasModified = false;

            foreach (var packageId in packageUpdates)
            {
                var regex = new Regex(string.Format(MsBuildProjectPackagesParser.PackageReferenceRegex, GlobRegex.ConvertToRegexPattern(packageId.Id).Expression));
                fileContent = regex.Replace(
                    fileContent,
                    m =>
                {
                    wasModified = true;
                    return(m.Groups[PrefixGroupName].Value + packageId.UpdatedNuGetVersion.ToFullString() + m.Groups[PostfixGroupName].Value);
                });
            }

            this.packageVersionUpdaterReporter.ProcessedProject(msBuildProject.Path, wasModified);
            return(Result.FromValue(wasModified, msBuildProject with {
                ProjectContent = fileContent
            }));
Ejemplo n.º 25
0
        private void ImportQMakeProject(FileInfo projectFile, VersionInformation vi)
        {
            var xmlProject = MsBuildProject.Load(projectFile.FullName);

            xmlProject.ReplacePath(vi.qtDir, "$(QTDIR)");
            xmlProject.ReplacePath(projectFile.DirectoryName, ".");

            bool ok = xmlProject.AddQtMsBuildReferences();

            if (ok)
            {
                ok = xmlProject.ConvertCustomBuildToQtMsBuild();
            }
            if (ok)
            {
                ok = xmlProject.EnableMultiProcessorCompilation();
            }
            if (ok)
            {
                string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion();
                if (!string.IsNullOrEmpty(versionWin10SDK))
                {
                    ok = xmlProject.SetDefaultWindowsSDKVersion(versionWin10SDK);
                }
            }
            if (ok)
            {
                ok = xmlProject.UpdateProjectFormatVersion();
            }

            if (!ok)
            {
                Messages.Print(
                    SR.GetString("ImportProject_CannotConvertProject", projectFile.Name));
            }
            xmlProject.Save();

            // Initialize Qt variables
            xmlProject.BuildTarget("QtVarsDesignTime");
        }
Ejemplo n.º 26
0
        static bool ConvertProject(string pathToProject)
        {
            var  xmlProject = MsBuildProject.Load(pathToProject);
            bool ok         = (xmlProject != null);

            if (ok)
            {
                ok = xmlProject.AddQtMsBuildReferences();
            }
            if (ok)
            {
                ok = xmlProject.ConvertCustomBuildToQtMsBuild();
            }
            if (ok)
            {
                ok = xmlProject.EnableMultiProcessorCompilation();
            }
            if (ok)
            {
                ok = xmlProject.Save();
            }
            return(ok);
        }
Ejemplo n.º 27
0
        protected MsBuildProject?ResolveProject(string?project)
        {
            //builder.Register(c =>
            //{
            //    MsBuildProject msBuild = MsBuildProject.FromFileOrDirectory(ProjectCollection.GlobalProjectCollection, fileOrDirectory);
            //    return new DotNetProjectInformationProvider(msBuild);
            //}).As<IProjectInformationProvider>();

            if (project == null)
            {
                project = Directory.GetCurrentDirectory();
                project = PathUtility.EnsureTrailingSlash(project);
            }

            try
            {
                return(MsBuildProject.FromFileOrDirectory(ProjectCollection.GlobalProjectCollection, project));
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 28
0
        public void RunStarted(object automation, Dictionary <string, string> replacements,
                               WizardRunKind runKind, object[] customParams)
        {
            var serviceProvider = new ServiceProvider(automation as IServiceProvider);
            var iVsUIShell      = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;

            iVsUIShell.EnableModeless(0);

            try {
                System.IntPtr hwnd;
                iVsUIShell.GetDialogOwnerHwnd(out hwnd);

                try {
                    var className = replacements["$safeprojectname$"];
                    className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty);
                    className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty);
                    var result = new ClassNameValidationRule().Validate(className, null);
                    if (result != ValidationResult.ValidResult)
                    {
                        className = @"QtGuiApplication";
                    }

                    data.ClassName       = className;
                    data.BaseClass       = @"QMainWindow";
                    data.ClassHeaderFile = className + @".h";
                    data.ClassSourceFile = className + @".cpp";
                    data.UiFile          = data.ClassName + @".ui";
                    data.QrcFile         = data.ClassName + @".qrc";

                    var wizard = new WizardWindow(new List <WizardPage> {
                        new IntroPage {
                            Data    = data,
                            Header  = @"Welcome to the Qt GUI Application Wizard",
                            Message = @"This wizard generates a Qt GUI application project. The "
                                      + @"application derives from QApplication and includes an empty "
                                      + @"widget." + System.Environment.NewLine
                                      + System.Environment.NewLine + "To continue, click Next.",
                            PreviousButtonEnabled = false,
                            NextButtonEnabled     = true,
                            FinishButtonEnabled   = false,
                            CancelButtonEnabled   = true
                        },
                        new ModulePage {
                            Data    = data,
                            Header  = @"Welcome to the Qt GUI Application Wizard",
                            Message = @"Select the modules you want to include in your project. The "
                                      + @"recommended modules for this project are selected by default.",
                            PreviousButtonEnabled = true,
                            NextButtonEnabled     = true,
                            FinishButtonEnabled   = false,
                            CancelButtonEnabled   = true
                        },
                        new GuiPage {
                            Data    = data,
                            Header  = @"Welcome to the Qt GUI Application Wizard",
                            Message = @"This wizard generates a Qt GUI application project. The "
                                      + @"application derives from QApplication and includes an empty "
                                      + @"widget.",
                            PreviousButtonEnabled = true,
                            NextButtonEnabled     = false,
                            FinishButtonEnabled   = data.DefaultModules.All(QtModuleInfo.IsInstalled),
                            CancelButtonEnabled   = true
                        }
                    })
                    {
                        Title = @"Qt GUI Application Wizard"
                    };
                    WindowHelper.ShowModal(wizard, hwnd);
                    if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value)
                    {
                        throw new System.Exception("Unexpected wizard return value.");
                    }
                } catch (QtVSException exception) {
                    Messages.DisplayErrorMessage(exception.Message);
                    throw; // re-throw, but keep the original exception stack intact
                }

                var version = (automation as DTE).Version;
                replacements["$ToolsVersion$"] = version;

                var vm = QtVersionManager.The();
                var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion()));
                replacements["$Platform$"] = vi.GetVSPlatformName();

                replacements["$Keyword$"]         = Resources.qtProjectKeyword;
                replacements["$ProjectGuid$"]     = @"{B12702AD-ABFB-343A-A199-8E24837244A3}";
                replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version);

                replacements["$classname$"]      = data.ClassName;
                replacements["$baseclass$"]      = data.BaseClass;
                replacements["$sourcefilename$"] = data.ClassSourceFile;
                replacements["$headerfilename$"] = data.ClassHeaderFile;
                replacements["$uifilename$"]     = data.UiFile;

                replacements["$precompiledheader$"]      = string.Empty;
                replacements["$precompiledsource$"]      = string.Empty;
                replacements["$DefaultApplicationIcon$"] = string.Empty;
                replacements["$centralwidget$"]          = string.Empty;

                var strHeaderInclude = data.ClassHeaderFile;
                if (data.UsePrecompiledHeader)
                {
                    strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile;
                    replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />";
                    replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />";
                }

                replacements["$include$"] = strHeaderInclude;
                replacements["$ui_hdr$"]  = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile)
                                            + ".h";
                replacements["$qrcfilename$"] = data.QrcFile;

                if (data.BaseClass == "QMainWindow")
                {
                    replacements["$centralwidget$"] =
                        "\r\n  <widget class=\"QMenuBar\" name=\"menuBar\" />"
                        + "\r\n  <widget class=\"QToolBar\" name=\"mainToolBar\" />"
                        + "\r\n  <widget class=\"QWidget\" name=\"centralWidget\" />"
                        + "\r\n  <widget class=\"QStatusBar\" name=\"statusBar\" />";
                }

                if (data.AddDefaultAppIcon)
                {
                    replacements["$DefaultApplicationIcon$"] = "<None Include=\"gui.ico\" />";
                }

                if (vi.isWinRT())
                {
                    replacements["$QtWinRT$"] = "true";

                    var projDir = replacements["$destinationdirectory$"];

                    var qmakeTmpDir = Path.Combine(projDir, "qmake_tmp");
                    Directory.CreateDirectory(qmakeTmpDir);

                    var dummyPro = Path.Combine(qmakeTmpDir,
                                                string.Format("{0}.pro", replacements["$projectname$"]));
                    File.WriteAllText(dummyPro, "SOURCES = main.cpp\r\n");

                    var qmake = new QMake(null, dummyPro, false, vi);
                    qmake.RunQMake();

                    var assetsDir = Path.Combine(qmakeTmpDir, "assets");
                    if (Directory.Exists(assetsDir))
                    {
                        Directory.Move(assetsDir, Path.Combine(projDir, "assets"));
                    }

                    var manifestFile = Path.Combine(qmakeTmpDir, "Package.appxmanifest");
                    if (File.Exists(manifestFile))
                    {
                        File.Move(manifestFile, Path.Combine(projDir, "Package.appxmanifest"));
                    }

                    var projFile = Path.Combine(qmakeTmpDir,
                                                string.Format("{0}.vcxproj", replacements["$projectname$"]));

                    var proj = MsBuildProject.Load(projFile);
                    replacements["$MinimumVisualStudioVersion$"] =
                        proj.GetProperty("MinimumVisualStudioVersion");
                    replacements["$ApplicationTypeRevision$"] =
                        proj.GetProperty("ApplicationTypeRevision");
                    replacements["$WindowsTargetPlatformVersion$"] =
                        proj.GetProperty("WindowsTargetPlatformVersion");
                    replacements["$isSet_WindowsTargetPlatformVersion$"] = "true";
                    replacements["$WindowsTargetPlatformMinVersion$"]    =
                        proj.GetProperty("WindowsTargetPlatformMinVersion");
                    replacements["$Link_TargetMachine$"] =
                        proj.GetProperty("Link", "TargetMachine");

                    Directory.Delete(qmakeTmpDir, true);
                }
#if (VS2017 || VS2015)
                else
                {
                    string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion();
                    if (!string.IsNullOrEmpty(versionWin10SDK))
                    {
                        replacements["$WindowsTargetPlatformVersion$"]       = versionWin10SDK;
                        replacements["$isSet_WindowsTargetPlatformVersion$"] = "true";
                    }
                }
#endif
            } catch {
                try {
                    Directory.Delete(replacements["$destinationdirectory$"]);
                    Directory.Delete(replacements["$solutiondirectory$"]);
                } catch { }

                iVsUIShell.EnableModeless(1);
                throw new WizardBackoutException();
            }

            iVsUIShell.EnableModeless(1);
        }
Ejemplo n.º 29
0
 protected virtual object GetReference(string name)
 {
     return(MsBuildProject.GetItems("Reference").FirstOrDefault(item => new AssemblyName(item.EvaluatedInclude).Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
 }
Ejemplo n.º 30
0
 protected virtual void Save()
 {
     MsBuildProject.CommitChanges();
 }