private void AddImportStatementForVS2013(ProjectImportLocation location, string relativeTargetPath) { NuGet.VisualStudio12.ProjectHelper.DoWorkInWriterLock( Project, Project.ToVsHierarchy(), buildProject => buildProject.AddImportStatement(relativeTargetPath, location)); }
public override void AddImport(string targetPath, ProjectImportLocation location) { if (VsVersionHelper.IsVisualStudio2010) { base.AddImport(targetPath, location); } else { // For VS 2012 or above, the operation has to be done inside the Writer lock if (String.IsNullOrEmpty(targetPath)) { throw new ArgumentNullException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "targetPath"); } string relativeTargetPath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(Root), targetPath); if (VsVersionHelper.IsVisualStudio2012) { Project.DoWorkInWriterLock(buildProject => NuGet.MSBuildProjectUtility.AddImportStatement(buildProject, relativeTargetPath, location)); Project.Save(this); } else { AddImportStatementForVS2013(location, relativeTargetPath); } } }
public override void AddImport(string targetPath, ProjectImportLocation location) { if (VsVersionHelper.IsVisualStudio2010) { base.AddImport(targetPath, location); } else { // For VS 2012 or above, the operation has to be done inside the Writer lock if (String.IsNullOrEmpty(targetPath)) { throw new ArgumentNullException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "targetPath"); } string relativeTargetPath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(Root), targetPath); if (VsVersionHelper.IsVisualStudio2012) { Project.DoWorkInWriterLock(buildProject => buildProject.AddImportStatement(relativeTargetPath, location)); Project.Save(this); } else { AddImportStatementForVS2013(location, relativeTargetPath); } } }
public void AddImport(string targetPath, ProjectImportLocation location) { string relativeTargetPath = GetRelativePath(targetPath); project.AddImportIfMissing(relativeTargetPath, location); projectService.Save(project); }
public void AddImport(string targetPath, ProjectImportLocation location) { GuiSyncDispatch(() => { string relativeTargetPath = GetRelativePath(targetPath); project.AddImportIfMissing(relativeTargetPath, null); project.Save(); }); }
public static void AddImport ( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation, string condition) { XmlElement import = project.AddImportElement (importedProjectFile, importLocation); import.SetAttribute ("Condition", condition); }
public void AddImport(string targetPath, ProjectImportLocation location) { GuiSyncDispatch(async() => { string relativeTargetPath = GetRelativePath(targetPath); string condition = GetCondition(relativeTargetPath); project.AddImportIfMissing(relativeTargetPath, condition); await project.SaveAsync(); }); }
public static void AddImport ( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation, string condition) { var before = importLocation == ProjectImportLocation.Top ? project.GetAllObjects ().FirstOrDefault () : null; project.AddNewImport (importedProjectFile, condition, before); }
private void AddImportStatementForVS2013(ProjectImportLocation location, string relativeTargetPath) { NuGetVS.ProjectHelper.DoWorkInWriterLock( Project, Project.ToVsHierarchy(), buildProject => NuGet.MSBuildProjectUtility.AddImportStatement(buildProject, relativeTargetPath, location)); // notify the project system of the change UpdateImportStamp(Project); }
static ProjectImportElement AddImport( ProjectRootElement projectRoot, string importedProjectFile, ProjectImportLocation importLocation) { if (importLocation == ProjectImportLocation.Top) { return AddImportAtTop(projectRoot, importedProjectFile); } return projectRoot.AddImport(importedProjectFile); }
public static void AddImport( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation, string condition) { XmlElement import = project.AddImportElement(importedProjectFile, importLocation); import.SetAttribute("Condition", condition); }
private void AddImportStatementForVS2013(ProjectImportLocation location, string relativeTargetPath) { NuGet.VisualStudio12.ProjectHelper.DoWorkInWriterLock( Project, Project.ToVsHierarchy(), buildProject => NuGet.MSBuildProjectUtility.AddImportStatement(buildProject, relativeTargetPath, location)); // notify the project system of the change UpdateImportStamp(Project); }
public static void AddImport( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation, string condition) { var before = importLocation == ProjectImportLocation.Top ? project.GetAllObjects().FirstOrDefault() : null; project.AddNewImport(importedProjectFile, condition, before); }
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); }
public void AddImport(string targetPath, ProjectImportLocation location) { if (location == ProjectImportLocation.Top) { _topImports.Add(targetPath); } else { _bottomImports.Add(targetPath); } }
public void AddImport(string targetPath, ProjectImportLocation location) { GuiSyncDispatch(async() => { string relativeTargetPath = GetRelativePath(targetPath); string condition = GetCondition(relativeTargetPath); using (var handler = CreateNewImportsHandler()) { handler.AddImportIfMissing(relativeTargetPath, condition, location); await project.SaveAsync(); } }); }
static ProjectImportElement AddImport( ProjectRootElement projectRoot, string importedProjectFile, ProjectImportLocation importLocation) { if (importLocation == ProjectImportLocation.Top) { return(AddImportAtTop(projectRoot, importedProjectFile)); } return(projectRoot.AddImport(importedProjectFile)); }
public bool ImportExists(string targetPath, ProjectImportLocation location) { if (location == ProjectImportLocation.Top) { return(_topImports.Contains(targetPath)); } else { return(_bottomImports.Contains(targetPath)); } }
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); }
public static void AddImportIfMissing ( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation, string condition) { if (project.ImportExists (importedProjectFile)) return; project.AddImport (importedProjectFile, importLocation, condition); }
public void AddImport(string targetFullPath, ProjectImportLocation location) { if (targetFullPath == null) { throw new ArgumentNullException("targetFullPath"); } var targetRelativePath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(Root), targetFullPath); NuGet.MSBuildProjectUtility.AddImportStatement(Project, targetRelativePath, location); Project.Save(); }
static XmlElement AddImportElement( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation) { if (importLocation == ProjectImportLocation.Top) { return project.AddImportElementAtTop (importedProjectFile); } XmlElement import = project.CreateImportElement (importedProjectFile); project.Document.DocumentElement.AppendChild (import); return import; }
public virtual void AddImport(string targetPath, ProjectImportLocation location) { if (String.IsNullOrEmpty(targetPath)) { throw new ArgumentNullException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "targetPath"); } string relativeTargetPath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(Root), targetPath); Project.AddImportStatement(relativeTargetPath, location); Project.Save(this); }
public static void AddImportIfMissing( this MSBuildBasedProject project, string importedProjectFile, ProjectImportLocation importLocation) { lock (project.SyncRoot) { if (project.ImportExists(importedProjectFile)) return; ProjectImportElement import = AddImport(project.MSBuildProjectFile, importedProjectFile, importLocation); import.Condition = GetCondition(importedProjectFile); } }
public static void AddImportIfMissing( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation, string condition) { if (project.ImportExists(importedProjectFile)) { return; } project.AddImport(importedProjectFile, importLocation, condition); }
static XmlElement AddImportElement( this MSBuildProject project, string importedProjectFile, ProjectImportLocation importLocation) { if (importLocation == ProjectImportLocation.Top) { return(project.AddImportElementAtTop(importedProjectFile)); } XmlElement import = project.CreateImportElement(importedProjectFile); project.Document.DocumentElement.AppendChild(import); return(import); }
public static void AddImportIfMissing( this MSBuildBasedProject project, string importedProjectFile, ProjectImportLocation importLocation) { lock (project.SyncRoot) { if (project.ImportExists(importedProjectFile)) { return; } ProjectImportElement import = AddImport(project.MSBuildProjectFile, importedProjectFile, importLocation); import.Condition = GetCondition(importedProjectFile); } }
public void AddImport(string targetPath, ProjectImportLocation location) { if (targetPath == null) { throw new ArgumentNullException("targetPath"); } // adds an <Import> element to this project file. if (Project.Xml.Imports == null || Project.Xml.Imports.All(import => !targetPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase))) { Project.Xml.AddImport(targetPath); Project.ReevaluateIfNecessary(); Project.Save(); } }
public void AddImport(string targetFullPath, ProjectImportLocation location) { if (targetFullPath == null) { throw new ArgumentNullException("targetFullPath"); } var targetRelativePath = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(Root), targetFullPath); // adds an <Import> element to this project file. if (Project.Xml.Imports == null || Project.Xml.Imports.All(import => !targetRelativePath.Equals(import.Project, StringComparison.OrdinalIgnoreCase))) { Project.Xml.AddImport(targetRelativePath); NuGet.MSBuildProjectUtility.AddEnsureImportedTarget(Project, targetRelativePath); Project.Save(); } }
/// <summary> /// Adds an Import element to this project file if it doesn't already exist. /// </summary> /// <param name="project">The project file.</param> /// <param name="targetsPath">The path to the imported file.</param> /// <param name="location">The location where the Import is added.</param> public static void AddImportStatement(MsBuildProject project, string targetsPath, ProjectImportLocation location) { if (project.Xml.Imports == null || project.Xml.Imports.All(import => !targetsPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase))) { ProjectImportElement pie = project.Xml.AddImport(targetsPath); pie.Condition = "Exists('" + targetsPath + "')"; if (location == ProjectImportLocation.Top) { // There's no public constructor to create a ProjectImportElement directly. // So we have to cheat by adding Import at the end, then remove it and insert at the beginning pie.Parent.RemoveChild(pie); project.Xml.InsertBeforeChild(pie, project.Xml.FirstChild); } NuGet.MSBuildProjectUtility.AddEnsureImportedTarget(project, targetsPath); project.ReevaluateIfNecessary(); } }
public void AddImport(string targetPath, ProjectImportLocation location) { throw new NotImplementedException("Not supported for websites"); }
public void AddImport(string targetPath, ProjectImportLocation location) { throw new NotSupportedException(); }
public void AddImport(string targetPath, ProjectImportLocation location) { }
public void AddImportIfMissing(string name, string condition, ProjectImportLocation location) { ImportsAdded.Add(new ImportAndCondition(name, condition, location)); }
public ImportAndCondition(string name, string condition, ProjectImportLocation location) { Name = name; Condition = condition; Location = location; }
public static void AddImportStatement(this MsBuildProject buildProject, string targetsPath, ProjectImportLocation location) { // adds an <Import> element to this project file if it doesn't already exist. if (buildProject.Xml.Imports == null || buildProject.Xml.Imports.All(import => !targetsPath.Equals(import.Project, StringComparison.OrdinalIgnoreCase))) { ProjectImportElement pie = buildProject.Xml.AddImport(targetsPath); pie.Condition = "Exists('" + targetsPath + "')"; if (location == ProjectImportLocation.Top) { // There's no public constructor to create a ProjectImportElement directly. // So we have to cheat by adding Import at the end, then remove it and insert at the beginning pie.Parent.RemoveChild(pie); buildProject.Xml.InsertBeforeChild(pie, buildProject.Xml.FirstChild); } else { // the import might get added into an ImportGroup. In this case, // we remove it from the ImportGroup and add it at the end of the // project. if (pie.Parent.GetType() == typeof(ProjectImportGroupElement)) { pie.Parent.RemoveChild(pie); buildProject.Xml.AppendChild(pie); } } NuGet.MSBuildProjectUtility.AddEnsureImportedTarget(buildProject, targetsPath); buildProject.ReevaluateIfNecessary(); } }
public bool ImportExists(string targetPath, ProjectImportLocation location) { if (location == ProjectImportLocation.Top) { return _topImports.Contains(targetPath); } else { return _bottomImports.Contains(targetPath); } }
public override void AddImport(string targetPath, ProjectImportLocation location) { // Web sites are not msbuild based and do not support imports. }
public void AddImport(string targetPath, ProjectImportLocation location) { string relativeTargetPath = GetRelativePath(targetPath); project.AddImportIfMissing(relativeTargetPath, location); ReevaluateProjectIfNecessary(); projectService.Save(project); }
public void AddImport(string targetPath, ProjectImportLocation location) { throw new NotImplementedException(); }
public void AddImportIfMissing(string name, string condition, ProjectImportLocation location) { this.name = name; this.condition = condition; this.location = location; }
public void AddImport(string targetPath, ProjectImportLocation location) { // Import statements do not apply to WebMatrix throw new NotImplementedException(); }
public void AddImport(string targetFullPath, ProjectImportLocation location) { throw new NotImplementedException(); }
public static void AddImportStatement(this Project project, string targetsPath, ProjectImportLocation location) { NuGet.MSBuildProjectUtility.AddImportStatement(project.AsMSBuildProject(), targetsPath, location); }