public static void AddImportIfMissing (
			this MSBuildProject project,
			string importedProjectFile,
			ImportLocation importLocation,
			string condition)
		{
			if (project.ImportExists (importedProjectFile))
				return;
			
			project.AddImport (importedProjectFile, importLocation, condition);
		}
Ejemplo n.º 2
0
        public static ProjectImportElement AddNewImport(this ProjectRootElement root, string filename, string label = null)
        {
            filename = filename.ChangeFileExtensionTo("props");
            var import = root.AddImport(filename);
            import.Condition = @"exists('{0}')".format(filename);

            if(!String.IsNullOrEmpty(label))
                import.Label = label;

            return import;
        }
 public static void EnsureImportExists(this ProjectRootElement project, string importedProject)
 {
     var existing = project.Imports.Where(p => p.Project.Equals(importedProject, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
     if (existing == null)
         project.AddImport(importedProject);
 }