Beispiel #1
0
        static void FixUpProject(MSBuildProject project)
        {
            var targetsBaseDirWindows = "$(MSBuildExtensionsPath32)\\Microsoft\\.NET Micro Framework\\";
            var targetsBaseDirOther   = "$([System.Environment]::GetFolderPath(SpecialFolder.LocalApplicationData))\\.NETMicroFramework\\xbuild\\Microsoft\\.NET Micro Framework\\";

            project.RemoveProperty("NetMfTargetsBaseDir");
            project.RemoveImport("$(MSBuildBinPath)\\Microsoft.CSharp.targets");
            project.RemoveImport("$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
            project.RemoveImport("$(NetMfTargetsBaseDir)$(TargetFrameworkVersion)\\CSharp.targets");
            project.AddImportIfMissing($"{targetsBaseDirWindows}$(TargetFrameworkVersion)\\CSharp.targets",
                                       condition: $"Exists('{targetsBaseDirWindows}$(TargetFrameworkVersion)\\CSharp.targets')");
            project.AddImportIfMissing($"{targetsBaseDirOther}$(TargetFrameworkVersion)\\CSharp.targets",
                                       condition: $"!Exists('{targetsBaseDirWindows}$(TargetFrameworkVersion)\\CSharp.targets')");
            project.Evaluate();
        }
        public void UpdateProject(MSBuildProject project)
        {
            if (String.IsNullOrEmpty(name))
            {
                return;
            }

            project.AddImportIfMissing(name, location, condition);
        }
Beispiel #3
0
        public static void AddImportIfMissing(
            this DotNetProject project,
            string importedProjectFile,
            ProjectImportLocation importLocation)
        {
            var msbuildProject = new MSBuildProject();

            msbuildProject.Load(project.FileName);
            msbuildProject.AddImportIfMissing(importedProjectFile, importLocation, GetCondition(importedProjectFile));
            msbuildProject.Save(project.FileName);
        }
 void AddImportIfMissingAtBottom(string importFile, string condition = "")
 {
     project.AddImportIfMissing(importFile, ProjectImportLocation.Bottom, condition);
 }