public GlobalProjectProperties(ProjectNode project) { msBuildProject = project.As<Project>(); dteProject = project.As<EnvDTE.Project>(); vsBuild = project.HierarchyNode.HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage; accessor = new DynamicPropertyAccessor(this); }
public void AddItemWithEmptyNameThrows() { ProjectNode projectNode = new ProjectNode(vsSolution, project.GUID); string itemName = ".cs"; string fullItemName = new FileInfo(itemName).FullName; projectNode.AddItem(itemName); }
public void SelectParentWillSelectAllChildrenExceptTheDisabledOnes() { // Arrange ProjectNode[] children = new ProjectNode[3]; // make two children enabled, one disabled for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsEnabled = i % 2 == 0 }; children[i] = node; } var folder = new FolderNode(null, "A", children); // Act folder.IsSelected = true; // Assert Assert.True(children[0].IsSelected == true); Assert.True(children[1].IsSelected == false); Assert.True(children[2].IsSelected == true); }
public TreeNode AddProjectNode(ExtTreeView classBrowser, IProject project) { ProjectNode prjNode = new ProjectNode(project); prjNode.AddTo(classBrowser); classBrowser.Sort(); return prjNode; }
public void TestAcceptsProjectReferenceToItSelf() { ProjectNode projectNode = new ProjectNode(vsSolution, project.GUID); int before = project.Children.Count; projectNode.AddProjectReference(project.GUID); Assert.AreEqual<int>(before,project.Children.Count); }
public IEnumerable<IDependencyNode> GetReferencesNeedCopy(ProjectNode dest) { var projectSources = dest.ProjectReferences.Where(r => r.CopyLocal) .Select(r => (IDependencyNode)r.Node); var assemblySources = dest.AssemblyReferences.Where(r => r.CopyLocal) .Select(LoadAssembly); return projectSources.Concat(assemblySources); }
public void TestCanAddItem() { ProjectNode projectNode = new ProjectNode(vsSolution, project.GUID); string itemName = "item1.cs"; Assert.IsTrue(projectNode.CanAddItem(itemName)); string invalidItemName = "<item1>.cs"; Assert.IsFalse(projectNode.CanAddItem(invalidItemName)); }
public void TestAddItem() { ProjectNode projectNode = new ProjectNode(vsSolution, project.GUID); string itemName = "item1.cs"; projectNode.AddItem(itemName); string fullItemName = new FileInfo(itemName).FullName; Assert.IsTrue(project.Children.Contains(fullItemName)); }
public OAProject(ProjectNode project) { this.project = project; if (project is ProjectContainerNode) { this.solutionFolder = new Microsoft.VisualStudio.Package.Automation.OASolutionFolder<ProjectContainerNode>((ProjectContainerNode)project); } }
public void NamePropertyIsCorrect() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act & Assert Assert.Equal("A", node.Name); }
public void IsSelectedFalseByDefault() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act & Assert Assert.True(node.IsSelected == false); }
public void ProjectPropertyIsCorrect() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act & Assert Assert.Same(project, node.Project); }
private static CopyLocalSet CreateCopyLocalSet(ProjectNode p, ResolveContext context) { return new CopyLocalSet { Dest = p, ProjectCopySource = context.GetProjectReferencesNeedCopy(p).ToArray(), AssemblyCopySource = context.GetAssemblyReferencesNeedCopy(p).ToArray(), RuntimeCopySources = context.GetRuntimeReferencesNeedCopy(p).ToArray() }; }
public ConfigProjectProperties(ProjectNode project, string configName) { this.project = project; this.configName = configName; vsBuild = project.HierarchyNode.HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage; if (vsBuild == null) tracer.Warn(Strings.ConfigProjectProperties.NonMsBuildProject(project.Text)); accessor = new DynamicPropertyAccessor(this); }
public UserProjectProperties(ProjectNode project) { this.project = project; msBuildProject = project.As<Project>(); dteProject = project.As<EnvDTE.Project>(); vsBuild = project.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage; if (msBuildProject == null || vsBuild == null) tracer.Warn(Strings.UserProjectProperties.NonMsBuildProject(project.DisplayName)); accessor = new DynamicPropertyAccessor(this); }
public void GetSelectedProjectReturnsEmptyIfIsSelectedIsFalse() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act node.IsSelected = false; // Assert Assert.False(node.GetSelectedProjects().Any()); }
public void GetSelectedProjectReturnsProjectIfIsSelectedIsTrueAndIsEnabledIsTrue() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act node.IsSelected = true; node.IsEnabled = true; // Assert Assert.Same(project, node.GetSelectedProjects().Single()); }
public ProjectNode BuildUp() { if (!cache.ContainsKey(projectFullPath)) { var extractor = new ProjectExtractor(projectFullPath, resolveConfig); var project = new ProjectNode { Id = extractor.GetId(), AssemblyReferences = GetAssemblyReferences(extractor), ProjectReferences = GetProjectReferences(extractor), RuntimeReferences = GetRuntimeReferences(extractor), FullPath = projectFullPath, Output = resolveConfig.GetAssemblyNameByProjectPath(projectFullPath) }; cache[projectFullPath] = project; } return cache[projectFullPath]; }
public static void AddProjectsToTree(Solution solution,ref Tree tree) { var projects = solution.Projects.ToList(); var allreadyAddedProjects = tree.DescendantNodes().OfType<ProjectNode>().ToList(); foreach (var project in projects) { var existingProject = allreadyAddedProjects.WithName(project.Name); if (existingProject != null) { existingProject.Documents = project.Documents.ToList(); } else { existingProject = new ProjectNode(project); tree.AddChild(existingProject); } } }
public void GetSelectedProjectReturnsEmptyIfIsSelectedIsFalseOrIsEnabledIsFalse() { // Arrange var project = MockProjectUtility.CreateMockProject("A"); var node = new ProjectNode(project); // Act node.IsSelected = false; node.IsEnabled = false; var result1 = node.GetSelectedProjects(); node.IsSelected = true; node.IsEnabled = false; var result2 = node.GetSelectedProjects(); node.IsSelected = false; node.IsEnabled = true; var result3 = node.GetSelectedProjects(); // Assert Assert.False(result1.Any()); Assert.False(result2.Any()); Assert.False(result3.Any()); }
internal MultiverseInterfacePythonFileNode(ProjectNode root, ProjectElement e) : base(root, e) { }
internal RustCrateDependencyNode(ProjectNode root, ProjectElement element) { }
public void ParentNodeIsEnabledIfAtLeastOneChildrenIsEnabled() { // Arrange var children = new ProjectNode[3]; // make two children enabled, one disabled for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsEnabled = i % 2 == 0 }; children[i] = node; } // Act var folder = new FolderNode(null, "A", children); // Assert Assert.True(folder.IsEnabled); }
public static bool GetProjectPropertyBool(ProjectNode node, string propertyname) { return(node.ProjectMgr.GetProjectProperty(propertyname) == "True"); }
/// <summary> /// Initializes a new instance of the <see cref="MyCustomProjectFileNode"/> class. /// </summary> /// <param name="root">The project node.</param> /// <param name="e">The project element node.</param> internal MyCustomProjectFileNode(ProjectNode root, ProjectElement e) : base(root, e) { }
public OAProject(ProjectNode project) { this.project = project; }
public PythonReferenceContainerNode(ProjectNode project) : base(project) { }
public OAProjectConfigurationProperties(ProjectNode node) { _project = node; AddEventSource <IPropertyNotifySink>(this); _hierarchyListener = new HierarchyListener(_project, this); }
private void WriteProject(SolutionNode solution, ProjectNode project) { string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); StreamWriter ss = new StreamWriter(projFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); bool hasDoc = false; using (ss) { ss.WriteLine("<?xml version=\"1.0\" ?>"); ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); ss.WriteLine(" <target name=\"{0}\">", "build"); ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">"); ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); foreach (ReferenceNode refr in project.References) { if (refr.LocalCopy) { ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/')); } } ss.WriteLine(" </fileset>"); ss.WriteLine(" </copy>"); ss.Write(" <csc"); ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); ss.Write(" debug=\"{0}\"", "${build.debug}"); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); break; } } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); break; } foreach (ConfigurationNode conf in project.Configurations) { ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); break; } foreach (ConfigurationNode conf in project.Configurations) { if (GetXmlDocFile(project, conf) != "") { ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); hasDoc = true; } break; } ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); if (project.Type == ProjectType.Library) { ss.Write(".dll\""); } else { ss.Write(".exe\""); } if (project.AppIcon != null && project.AppIcon.Length != 0) { ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); } ss.WriteLine(">"); ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); foreach (string file in project.Files) { switch (project.Files.GetBuildAction(file)) { case BuildAction.EmbeddedResource: ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); break; default: if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) { ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); } break; } } //if (project.Files.GetSubType(file).ToString() != "Code") //{ // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ss.WriteLine(" </resources>"); ss.WriteLine(" <sources failonempty=\"true\">"); foreach (string file in project.Files) { switch (project.Files.GetBuildAction(file)) { case BuildAction.Compile: ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); break; default: break; } } ss.WriteLine(" </sources>"); ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <lib>"); ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />"); ss.WriteLine(" </lib>"); foreach (ReferenceNode refr in project.References) { ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/')); } ss.WriteLine(" </references>"); ss.WriteLine(" </csc>"); ss.WriteLine(" </target>"); ss.WriteLine(" <target name=\"clean\">"); ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); ss.WriteLine(" </target>"); ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); if (hasDoc) { ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); ss.WriteLine(" </if>"); ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); if (project.Type == ProjectType.Library) { ss.WriteLine(".dll\" />"); } else { ss.WriteLine(".exe\" />"); } ss.WriteLine(" </assemblies>"); ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); ss.WriteLine(" </summaries>"); ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); ss.WriteLine(" <include name=\"${build.dir}\" />"); // foreach(ReferenceNode refr in project.References) // { // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); // if (path != "") // { // ss.WriteLine(" <include name=\"{0}\" />", path); // } // } ss.WriteLine(" </referencepaths>"); ss.WriteLine(" <documenters>"); ss.WriteLine(" <documenter name=\"MSDN\">"); ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); ss.WriteLine(" </documenter>"); ss.WriteLine(" </documenters>"); ss.WriteLine(" </ndoc>"); } ss.WriteLine(" </target>"); ss.WriteLine("</project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
public OAVSProject(ProjectNode project) { this.project = project; }
internal OABuildManager(ProjectNode project) { projectManager = project; AddEventSource <_dispBuildManagerEvents>(this as IEventSource <_dispBuildManagerEvents>); }
private void WriteProject(SolutionNode solution, ProjectNode project) { string csComp = "Mcs"; string netRuntime = "Mono"; if (project.Runtime == ClrRuntime.Microsoft) { csComp = "Csc"; netRuntime = "MsNet"; } string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); StreamWriter ss = new StreamWriter(projFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); using (ss) { ss.WriteLine( "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">", project.Name, project.RootNamespace ); int count = 0; ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); foreach (ConfigurationNode conf in project.Configurations) { ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name); ss.Write(" <Output"); ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString()))); ss.Write(" assembly=\"{0}\"", project.AssemblyName); ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) { ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); } else { ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); } if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) { ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); } else { ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); } ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); ss.WriteLine(" />"); ss.Write(" <Build"); ss.Write(" debugmode=\"True\""); if (project.Type == ProjectType.WinExe) { ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString()); } else { ss.Write(" target=\"{0}\"", project.Type); } ss.WriteLine(" />"); ss.Write(" <Execution"); ss.Write(" runwithwarnings=\"{0}\"", !conf.Options.WarningsAsErrors); ss.Write(" consolepause=\"True\""); ss.Write(" runtime=\"{0}\"", netRuntime); ss.Write(" clr-version=\"Net_2_0\""); ss.WriteLine(" />"); ss.Write(" <CodeGeneration"); ss.Write(" compiler=\"{0}\"", csComp); ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); ss.Write(" mainclass=\"{0}\"", project.StartupObject); ss.Write(" target=\"{0}\"", project.Type); ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); ss.Write(" win32Icon=\"{0}\"", project.AppIcon); ss.Write(" ctype=\"CSharpCompilerParameters\""); ss.WriteLine(" />"); ss.WriteLine(" </Configuration>"); count++; } ss.WriteLine(" </Configurations>"); ss.Write(" <DeploymentInformation"); ss.Write(" target=\"\""); ss.Write(" script=\"\""); ss.Write(" strategy=\"File\""); ss.WriteLine(">"); ss.WriteLine(" <excludeFiles />"); ss.WriteLine(" </DeploymentInformation>"); ss.WriteLine(" <Contents>"); foreach (string file in project.Files) { string buildAction = "Compile"; switch (project.Files.GetBuildAction(file)) { case BuildAction.None: buildAction = "Nothing"; break; case BuildAction.Content: buildAction = "Exclude"; break; case BuildAction.EmbeddedResource: buildAction = "EmbedAsResource"; break; default: buildAction = "Compile"; break; } // Sort of a hack, we try and resolve the path and make it relative, if we can. string filePath = PrependPath(file); ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); } ss.WriteLine(" </Contents>"); ss.WriteLine(" <References>"); foreach (ReferenceNode refr in project.References) { ss.WriteLine(" {0}", BuildReference(solution, refr)); } ss.WriteLine(" </References>"); ss.WriteLine("</Project>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
/// <summary> /// Constructor /// </summary> /// <param name="root">The root project node</param> /// <param name="referencedProjectName">The referenced project name</param> /// <param name="projectPath">The path to the project</param> /// <param name="projectReference">The project reference</param> public SandcastleBuilderProjectReferenceNode(ProjectNode root, string referencedProjectName, string projectPath, string projectReference) : base(root, referencedProjectName, projectPath, projectReference) { }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="root">The root project node</param> /// <param name="element">The project element</param> /// <overloads>There are two overloads for the constructor</overloads> public SandcastleBuilderProjectReferenceNode(ProjectNode root, ProjectElement element) : base(root, element) { }
public NemerleMacroAssemblyReferenceNode(ProjectNode root, ProjectElement e) : base(root, e) { }
public PythonConfigProvider(ProjectNode manager) : base(manager) { }
/// <summary> /// Find the first instance of a filenode with a given caption /// </summary> /// <param name="caption"></param> /// <returns></returns> private FileNode FindFileNode(ProjectNode project, string caption) { foreach(FileNode n in Utilities.GetNodesOfType<FileNode>(project)) { if(string.Compare(n.Caption, caption, true) == 0) return n; } return null; }
public VsProjectConfig(ProjectNode project, string configuration) : base(project, configuration) { }
private void WriteProject(SolutionNode solution, ProjectNode project) { string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); string projectDir = Path.Combine(solutionDir, project.Name); string projectVersion = project.Version; bool hasAssemblyConfig = false; chkMkDir(projectDir); List <string> compiledFiles = new List <string>(), contentFiles = new List <string>(), embeddedFiles = new List <string>(), binaryLibs = new List <string>(), pkgLibs = new List <string>(), systemLibs = new List <string>(), runtimeLibs = new List <string>(), extraDistFiles = new List <string>(), localCopyTargets = new List <string>(); // If there exists a .config file for this assembly, copy // it to the project folder // TODO: Support copying .config.osx files // TODO: support processing the .config file for native library deps string projectAssemblyName = project.Name; if (project.AssemblyName != null) { projectAssemblyName = project.AssemblyName; } if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) { hasAssemblyConfig = true; System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); extraDistFiles.Add(project.AssemblyName + ".dll.config"); } foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != string.Empty) { // Copy snk file into the project's directory // Use the snk from the project directory directly string source = Path.Combine(project.FullPath, conf.Options.KeyFile); string keyFile = conf.Options.KeyFile; Regex re = new Regex(".*/"); keyFile = re.Replace(keyFile, ""); string dest = Path.Combine(projectDir, keyFile); // Tell the user if there's a problem copying the file try { mkdirDashP(System.IO.Path.GetDirectoryName(dest)); System.IO.File.Copy(source, dest, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } } // Copy compiled, embedded and content files into the project's directory foreach (string filename in project.Files) { string source = Path.Combine(project.FullPath, filename); string dest = Path.Combine(projectDir, filename); if (filename.Contains("AssemblyInfo.cs")) { // If we've got an AssemblyInfo.cs, pull the version number from it string[] sources = { source }; string[] args = { "" }; Microsoft.CSharp.CSharpCodeProvider cscp = new Microsoft.CSharp.CSharpCodeProvider(); string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll"); System.CodeDom.Compiler.CompilerParameters cparam = new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile); System.CodeDom.Compiler.CompilerResults cr = cscp.CompileAssemblyFromFile(cparam, sources); foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) { Console.WriteLine("Error! '{0}'", error.ErrorText); } try { string projectFullName = cr.CompiledAssembly.FullName; Regex verRegex = new Regex("Version=([\\d\\.]+)"); Match verMatch = verRegex.Match(projectFullName); if (verMatch.Success) { projectVersion = verMatch.Groups[1].Value; } }catch { Console.WriteLine("Couldn't compile AssemblyInfo.cs"); } // Clean up the temp file try { if (File.Exists(tempAssemblyFile)) { File.Delete(tempAssemblyFile); } } catch { Console.WriteLine("Error! '{0}'", e); } } // Tell the user if there's a problem copying the file try { mkdirDashP(System.IO.Path.GetDirectoryName(dest)); System.IO.File.Copy(source, dest, true); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } switch (project.Files.GetBuildAction(filename)) { case BuildAction.Compile: compiledFiles.Add(filename); break; case BuildAction.Content: contentFiles.Add(filename); extraDistFiles.Add(filename); break; case BuildAction.EmbeddedResource: embeddedFiles.Add(filename); break; } } // Set up references for (int refNum = 0; refNum < project.References.Count; refNum++) { ReferenceNode refr = project.References[refNum]; Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); /* Determine which pkg-config (.pc) file refers to * this assembly */ SystemPackage package = null; if (packagesHash.ContainsKey(refr.Name)) { package = packagesHash[refr.Name]; } else { string assemblyFullName = string.Empty; if (refAssembly != null) { assemblyFullName = refAssembly.FullName; } string assemblyFileName = string.Empty; if (assemblyFullName != string.Empty && assemblyFullNameToPath.ContainsKey(assemblyFullName) ) { assemblyFileName = assemblyFullNameToPath[assemblyFullName]; } if (assemblyFileName != string.Empty && assemblyPathToPackage.ContainsKey(assemblyFileName) ) { package = assemblyPathToPackage[assemblyFileName]; } } /* If we know the .pc file and it is not "mono" * (already in the path), add a -pkg: argument */ if (package != null && package.Name != "mono" && !pkgLibs.Contains(package.Name) ) { pkgLibs.Add(package.Name); } string fileRef = FindFileReference(refr.Name, (ProjectNode)refr.Parent); if (refr.LocalCopy || solution.ProjectsTable.ContainsKey(refr.Name) || fileRef != null || refr.Path != null ) { /* Attempt to copy the referenced lib to the * project's directory */ string filename = refr.Name + ".dll"; string source = filename; if (refr.Path != null) { source = Path.Combine(refr.Path, source); } source = Path.Combine(project.FullPath, source); string dest = Path.Combine(projectDir, filename); /* Since we depend on this binary dll to build, we * will add a compile- time dependency on the * copied dll, and add the dll to the list of * files distributed with this package */ binaryLibs.Add(refr.Name + ".dll"); extraDistFiles.Add(refr.Name + ".dll"); // TODO: Support copying .config.osx files // TODO: Support for determining native dependencies if (File.Exists(source + ".config")) { System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); extraDistFiles.Add(refr.Name + ".dll.config"); } try { System.IO.File.Copy(source, dest, true); } catch (System.IO.IOException) { if (solution.ProjectsTable.ContainsKey(refr.Name)) { /* If an assembly is referenced, marked for * local copy, in the list of projects for * this solution, but does not exist, put a * target into the Makefile.am to build the * assembly and copy it to this project's * directory */ ProjectNode sourcePrj = ((solution.ProjectsTable[refr.Name])); string target = String.Format("{0}:\n" + "\t$(MAKE) -C ../{1}\n" + "\tln ../{2}/$@ $@\n", filename, sourcePrj.Name, sourcePrj.Name); localCopyTargets.Add(target); } } } else if (!pkgLibs.Contains(refr.Name)) { // Else, let's assume it's in the GAC or the lib path string assemName = string.Empty; int index = refr.Name.IndexOf(","); if (index > 0) { assemName = refr.Name.Substring(0, index); } else { assemName = refr.Name; } m_Kernel.Log.Write(String.Format( "Warning: Couldn't find an appropriate assembly " + "for reference:\n'{0}'", refr.Name )); systemLibs.Add(assemName); } } const string lineSep = " \\\n\t"; string compiledFilesString = string.Empty; if (compiledFiles.Count > 0) { compiledFilesString = lineSep + string.Join(lineSep, compiledFiles.ToArray()); } string embeddedFilesString = ""; if (embeddedFiles.Count > 0) { embeddedFilesString = lineSep + string.Join(lineSep, embeddedFiles.ToArray()); } string contentFilesString = ""; if (contentFiles.Count > 0) { contentFilesString = lineSep + string.Join(lineSep, contentFiles.ToArray()); } string extraDistFilesString = ""; if (extraDistFiles.Count > 0) { extraDistFilesString = lineSep + string.Join(lineSep, extraDistFiles.ToArray()); } string pkgLibsString = ""; if (pkgLibs.Count > 0) { pkgLibsString = lineSep + string.Join(lineSep, pkgLibs.ToArray()); } string binaryLibsString = ""; if (binaryLibs.Count > 0) { binaryLibsString = lineSep + string.Join(lineSep, binaryLibs.ToArray()); } string systemLibsString = ""; if (systemLibs.Count > 0) { systemLibsString = lineSep + string.Join(lineSep, systemLibs.ToArray()); } string localCopyTargetsString = ""; if (localCopyTargets.Count > 0) { localCopyTargetsString = string.Join("\n", localCopyTargets.ToArray()); } string monoPath = ""; foreach (string runtimeLib in runtimeLibs) { monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; } // Add the project name to the list of transformation // parameters XsltArgumentList argList = new XsltArgumentList(); argList.AddParam("projectName", "", project.Name); argList.AddParam("solutionName", "", solution.Name); argList.AddParam("assemblyName", "", projectAssemblyName); argList.AddParam("compiledFiles", "", compiledFilesString); argList.AddParam("embeddedFiles", "", embeddedFilesString); argList.AddParam("contentFiles", "", contentFilesString); argList.AddParam("extraDistFiles", "", extraDistFilesString); argList.AddParam("pkgLibs", "", pkgLibsString); argList.AddParam("binaryLibs", "", binaryLibsString); argList.AddParam("systemLibs", "", systemLibsString); argList.AddParam("monoPath", "", monoPath); argList.AddParam("localCopyTargets", "", localCopyTargetsString); argList.AddParam("projectVersion", "", projectVersion); argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : ""); // Transform the templates transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc"); transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm"); transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh"); if (project.Type == Core.Nodes.ProjectType.Library) { transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); } if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe) { transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); } }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); #region Project File using (ps) { string targets = ""; if (project.Files.CopyFiles > 0) { targets = "Build;CopyFiles"; } else { targets = "Build"; } ps.WriteLine("<Project DefaultTargets=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {1}>", targets, GetToolsVersionXml(project.FrameworkVersion)); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ProjectType>Local</ProjectType>"); ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion); ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion); ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); // Visual Studio has a hard coded guid for the project type if (project.Type == ProjectType.Web) { ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); } ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); ps.WriteLine(" <AssemblyKeyContainerName>"); ps.WriteLine(" </AssemblyKeyContainerName>"); ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); ps.WriteLine(" <SignAssembly>true</SignAssembly>"); break; } } ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); ps.WriteLine(" <DelaySign>false</DelaySign>"); ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", ".")); ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); if (string.IsNullOrEmpty(project.DebugStartParameters)) { ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters); } ps.WriteLine(" <FileUpgradeFlags>"); ps.WriteLine(" </FileUpgradeFlags>"); ps.WriteLine(" </PropertyGroup>"); if (!string.IsNullOrEmpty(project.ApplicationManifest)) { ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ApplicationManifest>"+ project.ApplicationManifest + "</ApplicationManifest>"); ps.WriteLine(" </PropertyGroup>"); } foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup "); ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform); ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); ps.WriteLine(" <ConfigurationOverrideFile>"); ps.WriteLine(" </ConfigurationOverrideFile>"); ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"].ToString() == "" ? this.kernel.ForcedConditionals : conf.Options["CompilerDefines"] + ";" + kernel.ForcedConditionals); ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); if (project.Type != ProjectType.Web) { ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); } else { ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath("bin\\"))); } ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]); ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform); ps.WriteLine(" <Prefer32Bit>false</Prefer32Bit>"); ps.WriteLine(" </PropertyGroup>"); } //ps.WriteLine(" </Settings>"); Dictionary <ReferenceNode, ProjectNode> projectReferences = new Dictionary <ReferenceNode, ProjectNode>(); List <ReferenceNode> otherReferences = new List <ReferenceNode>(); foreach (ReferenceNode refr in project.References) { ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); if (projectNode == null) { otherReferences.Add(refr); } else { projectReferences.Add(refr, projectNode); } } // Assembly References ps.WriteLine(" <ItemGroup>"); foreach (ReferenceNode refr in otherReferences) { ps.Write(" <Reference"); ps.Write(" Include=\""); ps.Write(refr.Name); ps.WriteLine("\" >"); ps.Write(" <Name>"); ps.Write(refr.Name); ps.WriteLine("</Name>"); if (!String.IsNullOrEmpty(refr.Path)) { // Use absolute path to assembly (for determining assembly type) string absolutePath = Path.Combine(project.FullPath, refr.Path); if (File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { // Assembly is an executable (exe) ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); } else if (File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { // Assembly is an library (dll) ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); } else { string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); } } ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); ps.WriteLine(" </Reference>"); } ps.WriteLine(" </ItemGroup>"); //Project References ps.WriteLine(" <ItemGroup>"); foreach (KeyValuePair <ReferenceNode, ProjectNode> pair in projectReferences) { ToolInfo tool = tools[pair.Value.Language]; if (tools == null) { throw new UnknownLanguageException(); } string path = Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); ps.WriteLine(" <ProjectReference Include=\"{0}\">", path); // TODO: Allow reference to visual basic projects ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name); ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper()); ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); //This is the Copy Local flag in VS ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy); ps.WriteLine(" </ProjectReference>"); } ps.WriteLine(" </ItemGroup>"); // ps.WriteLine(" </Build>"); ps.WriteLine(" <ItemGroup>"); // ps.WriteLine(" <Include>"); List <string> list = new List <string>(); foreach (string path in project.Files) { string lower = path.ToLower(); if (lower.EndsWith(".resx")) { string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); if (!list.Contains(codebehind)) { list.Add(codebehind); } } } foreach (string filePath in project.Files) { // Add the filePath with the destination as the key // will use it later to form the copy parameters with Include lists // for each destination if (project.Files.GetBuildAction(filePath) == BuildAction.Copy) { continue; } // if (file == "Properties\\Bind.Designer.cs") // { // Console.WriteLine("Wait a minute!"); // Console.WriteLine(project.Files.GetSubType(file).ToString()); // } SubType subType = project.Files.GetSubType(filePath); // Visual Studio chokes on file names if forward slash is used as a path separator // instead of backslash. So we must make sure that all file paths written to the // project file use \ as a path separator. string file = filePath.Replace(@"/", @"\"); if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer && subType != SubType.CodeBehind) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); ps.WriteLine(" <SubType>Designer</SubType>"); ps.WriteLine(" </EmbeddedResource>"); // } if (subType == SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; // Check for a parent .cs file with the same name as this designer file if (File.Exists(Helper.NormalizePath(dependent_name))) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); } else { ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name)); ps.WriteLine(" <SubType>"+ subType + "</SubType>"); } ps.WriteLine(" </EmbeddedResource>"); if (File.Exists(Helper.NormalizePath(autogen_name))) { ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); //ps.WriteLine(" <DesignTime>True</DesignTime>"); // If a parent .cs file exists, link this autogen file to it. Otherwise link // to the designer file if (File.Exists(dependent_name)) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); } else { ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath)); } ps.WriteLine(" </Compile>"); } list.Add(autogen_name); } if (subType == SubType.Settings) { ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); ps.WriteLine("Include=\"{0}\">", file); string fileName = Path.GetFileName(filePath); if (project.Files.GetBuildAction(filePath) == BuildAction.None) { ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } else { ps.WriteLine(" <SubType>Code</SubType>"); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); } else if (subType != SubType.Designer) { string path = Helper.NormalizePath(file); string path_lower = path.ToLower(); if (!list.Contains(filePath)) { ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); int startPos = 0; if (project.Files.GetPreservePath(filePath)) { while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) { startPos++; } } else { startPos = file.LastIndexOf(Path.GetFileName(path)); } // be sure to write out the path with backslashes so VS recognizes // the file properly. ps.WriteLine("Include=\"{0}\">", file); int last_period_index = file.LastIndexOf('.'); string short_file_name = (last_period_index >= 0) ? file.Substring(0, last_period_index) : file; string extension = Path.GetExtension(path); // make this upper case, so that when File.Exists tests for the // existence of a designer file on a case-sensitive platform, // it is correctly identified. string designer_format = string.Format(".Designer{0}", extension); if (path_lower.EndsWith(designer_format.ToLowerInvariant())) { int designer_index = path.IndexOf(designer_format); string file_name = path.Substring(0, designer_index); // There are two corrections to the next lines: // 1. Fix the connection between a designer file and a form // or usercontrol that don't have an associated resx file. // 2. Connect settings files to associated designer files. if (File.Exists(file_name + extension)) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension)); } else if (File.Exists(file_name + ".resx")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); } else if (File.Exists(file_name + ".settings")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings")); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); } } else if (subType == SubType.CodeBehind) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); } if (project.Files.GetIsLink(filePath)) { string alias = project.Files.GetLinkPath(filePath); alias += file.Substring(startPos); alias = Helper.NormalizePath(alias); ps.WriteLine(" <Link>{0}</Link>", alias); } else if (project.Files.GetBuildAction(filePath) != BuildAction.None) { if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) { ps.WriteLine(" <SubType>{0}</SubType>", subType); } } if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) { ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath)); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); } } } ps.WriteLine(" </ItemGroup>"); /* * Copy Task * */ if (project.Files.CopyFiles > 0) { Dictionary <string, string> IncludeTags = new Dictionary <string, string>(); int TagCount = 0; // Handle Copy tasks ps.WriteLine(" <ItemGroup>"); foreach (string destPath in project.Files.Destinations) { string tag = "FilesToCopy_" + TagCount.ToString("0000"); ps.WriteLine(" <{0} Include=\"{1}\" />", tag, String.Join(";", project.Files.SourceFiles(destPath))); IncludeTags.Add(destPath, tag); TagCount++; } ps.WriteLine(" </ItemGroup>"); ps.WriteLine(" <Target Name=\"CopyFiles\">"); foreach (string destPath in project.Files.Destinations) { ps.WriteLine(" <Copy SourceFiles=\"@({0})\" DestinationFolder=\"{1}\" />", IncludeTags[destPath], destPath); } ps.WriteLine(" </Target>"); } ps.WriteLine(" <Import Project=\""+ toolInfo.ImportProject + "\" />"); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PreBuildEvent>"); ps.WriteLine(" </PreBuildEvent>"); ps.WriteLine(" <PostBuildEvent>"); ps.WriteLine(" </PostBuildEvent>"); ps.WriteLine(" </PropertyGroup>"); ps.WriteLine("</Project>"); } #endregion #region User File ps = new StreamWriter(projectFile + ".user"); using (ps) { // Get the first configuration from the project. ConfigurationNode firstConfiguration = null; if (project.Configurations.Count > 0) { firstConfiguration = project.Configurations[0]; } ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine( "<VisualStudioProject>" ); //ps.WriteLine(" <{0}>", toolInfo.XMLTag); //ps.WriteLine(" <Build>"); ps.WriteLine(" <PropertyGroup>"); //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); if (firstConfiguration != null) { ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform); } ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion); ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup"); ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform); ps.WriteLine(" />"); } ps.WriteLine("</Project>"); } #endregion kernel.CurrentWorkingDirectory.Pop(); }
internal FoxProFileNode(ProjectNode root, ProjectElement e) : base(root, e) { selectionChangedListener = new SelectionElementValueChangedListener(new ServiceProvider((IOleServiceProvider)root.GetService(typeof(IOleServiceProvider))), root); selectionChangedListener.Init(); }
private void WriteProject(SolutionNode solution, TextWriter ss, ProjectNode project) { WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath); }
public void AddItemWithNullNameThrows() { ProjectNode projectNode = new ProjectNode(vsSolution, project.GUID); projectNode.AddItem(null); }
private void WriteProject(StreamWriter f, SolutionNode solution, ProjectNode project) { f.WriteLine("# This is for project {0}", project.Name); f.WriteLine(); WriteProjectFiles(f, solution, project); WriteProjectReferences(f, solution, project); WriteProjectDependencies(f, solution, project); bool clash = ProjectClashes(project); foreach (ConfigurationNode conf in project.Configurations) { string outpath = ProjectOutput(project, conf); string filesToClean = outpath; if (clash) { f.WriteLine("{0}-{1}: .{0}-{1}-timestamp", project.Name, conf.Name); f.WriteLine(); f.Write(".{0}-{1}-timestamp: $(DEPENDENCIES_{0})", project.Name, conf.Name); } else { f.WriteLine("{0}-{1}: {2}", project.Name, conf.Name, outpath); f.WriteLine(); f.Write("{2}: $(DEPENDENCIES_{0})", project.Name, conf.Name, outpath); } // Dependencies on other projects. foreach (ReferenceNode refr in project.References) { if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProj = (ProjectNode)solution.ProjectsTable[refr.Name]; if (ProjectClashes(refProj)) { f.Write(" .{0}-{1}-timestamp", refProj.Name, conf.Name); } else { f.Write(" {0}", ProjectOutput(refProj, conf)); } } } f.WriteLine(); // make directory for output. if (Path.GetDirectoryName(outpath) != "") { f.WriteLine("\tmkdir -p {0}", Path.GetDirectoryName(outpath)); } // mcs command line. f.Write("\tgmcs", project.Name); f.Write(" -warn:{0}", conf.Options["WarningLevel"]); if ((bool)conf.Options["DebugInformation"]) { f.Write(" -debug"); } if ((bool)conf.Options["AllowUnsafe"]) { f.Write(" -unsafe"); } if ((bool)conf.Options["CheckUnderflowOverflow"]) { f.Write(" -checked"); } if (project.StartupObject != "") { f.Write(" -main:{0}", project.StartupObject); } if ((string)conf.Options["CompilerDefines"] != "") { f.Write(" -define:\"{0}\"", conf.Options["CompilerDefines"]); } f.Write(" -target:{0} -out:{1}", ProjectTypeToTarget(project.Type), outpath); // Build references to other projects. Now that sux. // We have to reference the other project in the same conf. foreach (ReferenceNode refr in project.References) { if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProj; refProj = (ProjectNode)solution.ProjectsTable[refr.Name]; f.Write(" -r:{0}", ProjectOutput(refProj, conf)); } } f.Write(" $(REFERENCES_{0})", project.Name); f.Write(" $(RESOURCES_{0})", project.Name); f.Write(" $(SOURCES_{0})", project.Name); f.WriteLine(); // Copy references with localcopy. foreach (ReferenceNode refr in project.References) { if (refr.LocalCopy) { string outPath, srcPath, destPath; outPath = Helper.NormalizePath((string)conf.Options["OutputPath"]); if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProj; refProj = (ProjectNode)solution.ProjectsTable[refr.Name]; srcPath = ProjectOutput(refProj, conf); destPath = Path.Combine(outPath, Path.GetFileName(srcPath)); destPath = NicePath(project, destPath); if (srcPath != destPath) { f.WriteLine("\tcp -f {0} {1}", srcPath, destPath); filesToClean += " " + destPath; } continue; } srcPath = FindFileReference(refr.Name, project); if (srcPath != null) { destPath = Path.Combine(outPath, Path.GetFileName(srcPath)); destPath = NicePath(project, destPath); f.WriteLine("\tcp -f {0} {1}", srcPath, destPath); filesToClean += " " + destPath; } } } if (clash) { filesToClean += String.Format(" .{0}-{1}-timestamp", project.Name, conf.Name); f.WriteLine("\ttouch .{0}-{1}-timestamp", project.Name, conf.Name); f.Write("\trm -rf"); foreach (ConfigurationNode otherConf in project.Configurations) { if (otherConf != conf) { f.WriteLine(" .{0}-{1}-timestamp", project.Name, otherConf.Name); } } f.WriteLine(); } f.WriteLine(); f.WriteLine("{0}-{1}-clean:", project.Name, conf.Name); f.WriteLine("\trm -rf {0}", filesToClean); f.WriteLine(); } }
internal static PythonProjectNode GetPythonProject(this ProjectNode project) { return(((IVsHierarchy)project).GetPythonProject()); }
internal OAProject(ProjectNode project) { this.project = project; }
public void ParentNodeIsDisabledIfAllChildrenAreDisabled() { // Arrange var children = new ProjectNode[3]; // disable all children for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project) { IsEnabled = false }; children[i] = node; } // Act var folder = new FolderNode(null, "A", children); // Assert Assert.False(folder.IsEnabled); }
/// <summary> /// Constructor /// </summary> /// <param name="root">The root project node</param> /// <param name="assemblyPath">The path to the assembly</param> public SandcastleBuilderAssemblyReferenceNode(ProjectNode root, string assemblyPath) : base(root, assemblyPath) { }
private FolderNode CreateFolderNode(string name = "A", ICollection<ProjectNodeBase> children = null) { if (children == null) { children = new List<ProjectNodeBase>(); for (int i = 0; i < 3; i++) { var project = MockProjectUtility.CreateMockProject("p" + i); var node = new ProjectNode(project); children.Add(node); } } return new FolderNode(null, name, children); }
private void TestImplicitNestedProjectReload(IServiceProvider sp, ProjectNode project, int dialogAnswer) { // Save everything. IVsSolution solutionService = (IVsSolution)sp.GetService(typeof(IVsSolution)); solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, project.InteropSafeIVsHierarchy, 0); IVsProject3 nestedProject = Utilities.GetNestedHierarchy(project, "ANestedProject") as IVsProject3; if (nestedProject == null) { throw new InvalidOperationException("The nested project has not been loaded corectly"); } string nestedProjectFileName = null; nestedProject.GetMkDocument(VSConstants.VSITEMID_ROOT, out nestedProjectFileName); if (nestedProjectFileName == null) { throw new InvalidOperationException("The nested project file name could not been retrieved corectly"); } string resourceText = Utilities.GetResourceStringFromTheProjectAssembly("QueryReloadNestedProject"); // Create the messageBoxListener Thread. This will bring up the reload of the nested project file. // In this scenario we will answer dialogAnswer. Also we rely on the exact messagebox text here. string message = String.Format(System.Globalization.CultureInfo.CurrentCulture, resourceText, nestedProjectFileName); DialogBoxPurger purger = new DialogBoxPurger(dialogAnswer, message); bool result = false; try { purger.Start(); this.AddReferenceExternallyToTheProjectFile(nestedProjectFileName); } finally { result = purger.WaitForDialogThreadToTerminate(); } if (!result) { throw new InvalidOperationException("The messagebox for relaoding the nested project file has never popped up"); } // Check to see if the nested project is there. EnvDTE.Project projectDTE = Utilities.GetAutomationObject(project); EnvDTE.ProjectItem item = projectDTE.ProjectItems.Item("ANestedProject"); Assert.IsNotNull(item, "The nested project has not been loaded correctly."); EnvDTE.Project nestedAutomationProject = item.SubProject; // Now check to see if we can find the added reference VSLangProj.VSProject automationProject = nestedAutomationProject.Object as VSLangProj.VSProject; if (nestedAutomationProject == null) { throw new InvalidOperationException("The nested project is not a vs language project"); } // Get references collection VSLangProj.References references = automationProject.References; IEnumerator enumerator = references.GetEnumerator(); bool found = false; while (enumerator.MoveNext()) { VSLangProj.Reference reference = enumerator.Current as VSLangProj.Reference; if (reference.Name == BuildEngineRef) { found = true; } } if (dialogAnswer == NativeMethods.IDYES) { Assert.IsTrue(found, "The nested project file has not been reloaded correctly"); } else { Assert.IsFalse(found, "The nested project file has been reloaded but was asked not to do that."); } }
public BooProjectNodeProperties(ProjectNode node) : base(node) { }
public SelectionElementValueChangedListener(ServiceProvider serviceProvider, ProjectNode proj) : base(serviceProvider) { projMgr = proj; }
TreeNode AddWebReferenceToProjectNode(ProjectNode node, WebReference webReference) { TreeNode webReferencesNode = WebReferenceNodeBuilder.AddWebReferencesFolderNode(node, webReference); if (webReferencesNode == null) { webReferencesNode = GetWebReferencesFolderNode((ProjectNode)node); if (webReferencesNode != null) { WebReferenceNodeBuilder.AddWebReference((WebReferencesFolderNode)webReferencesNode, webReference); } } return webReferencesNode; }
private FileNode GetFirstFileNode(ProjectNode project) { List<FileNode> nodes = Utilities.GetNodesOfType<FileNode>(project); foreach(FileNode node in nodes) { if(String.Compare(Path.GetExtension(node.GetMkDocument()), ".cs", StringComparison.OrdinalIgnoreCase) == 0) { return node; } } return null; }
private void presentFiles(Novel8rProject pro) { _view.tvwProject.BeginUpdate(); _view.tvwProject.Nodes.Clear(); var pNode = new ProjectNode(pro.Name, pro.BaseDir); _view.tvwProject.Nodes.Add(pNode); foreach (Sql8rProjectFile file in pro.ProjectFiles) { string relName = file.Path.Replace(pNode.FolderObject.FullName, ""); if (relName.StartsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.OrdinalIgnoreCase)) { relName = relName.Substring(1, relName.Length - 1); } UltraTreeNode parentNode = pNode; if (relName.Contains(Path.DirectorySeparatorChar.ToString())) { IList <string> partlist = relName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < partlist.Count - 1; i++) { string s = Path.Combine(pNode.FolderObject.FullName, partlist[i]); var di = new DirectoryInfo(s); var foNode = new FolderNode(di); if (!parentNode.Nodes.Exists(foNode.Key)) { parentNode.Nodes.Add(foNode); parentNode = foNode; } else { parentNode = parentNode.Nodes[foNode.Key]; } } } var fiNode = new FileNode(new FileInfo(file.Path)); parentNode.Nodes.Add(fiNode); } foreach (Sql8rProjectFolder folder in pro.ProjectFolders) { string relName = folder.Path.Replace(pNode.FolderObject.FullName, ""); if (relName.StartsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.OrdinalIgnoreCase)) { relName = relName.Substring(1, relName.Length - 1); } UltraTreeNode parentNode = pNode; if (relName.Contains(Path.DirectorySeparatorChar.ToString())) { IList <string> partlist = relName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < partlist.Count - 1; i++) { string s = Path.Combine(pNode.FolderObject.FullName, partlist[i]); var di = new DirectoryInfo(s); var foNode = new FolderNode(di); if (!parentNode.Nodes.Exists(foNode.Key)) { parentNode.Nodes.Add(foNode); parentNode = foNode; } else { parentNode = parentNode.Nodes[foNode.Key]; } } } var parentFolderNode = new FolderNode(new DirectoryInfo(folder.Path)); if (!parentNode.Nodes.Exists(parentFolderNode.Key)) { parentNode.Nodes.Add(parentFolderNode); } } pNode.Expanded = true; pNode.Selected = true; _view.tvwProject.EndUpdate(); }
TreeNode GetWebReferencesFolderNode(ProjectNode projectNode) { foreach (TreeNode node in projectNode.Nodes) { WebReferencesFolderNode webReferencesNode = node as WebReferencesFolderNode; if (webReferencesNode != null) { return webReferencesNode; } } return null; }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="root">The root project node</param> /// <param name="docSource">The <see cref="XElement"/> representing the documentation source</param> public DocumentationSourceNode(ProjectNode root, XElement docSource) : base(root) { this.DocumentationSource = docSource; this.ExcludeNodeFromScc = true; }
public DelphiMainFileNode(ProjectNode root, ProjectElement e) : base(root, e) { }
private void createFile(string fileType) { string typeSpecificFileName = string.Empty; if (fileType == MainPresenter.FileTypes.SQL) { typeSpecificFileName = "untitled.sql"; } else if (fileType == MainPresenter.FileTypes.RTF) { typeSpecificFileName = "untitled.rtf"; } if (_view.tvwProject.SelectedNodes != null && _view.tvwProject.SelectedNodes.Count > 0) { // TODO: maybe ProjectNode should inherit from FolderNode UltraTreeNode node = _view.tvwProject.SelectedNodes[0]; if (node is ProjectNode) { var pNode = node as ProjectNode; DirectoryInfo dir = pNode.FolderObject; var file = new FileInfo(dir + @"\" + typeSpecificFileName); if (!file.Exists) { FileStream fs = file.Create(); fs.Close(); var fiNode = new FileNode(file); node.Nodes.Add(fiNode); node.Expanded = true; Novel8rProjectHandler.Instance.AddFile(fiNode.GetFilePath()); fiNode.BeginEdit(); } else { MessageBox.Show("File already exists in project", DialogHelper.Instance.GetApplicationName()); } } else if (node is FolderNode) { ProjectNode pn = getProjectNode(node); var foNode = node as FolderNode; // DirectoryInfo dir = pNode.FolderObject; string dirName = foNode.FullPath; var sb = new StringBuilder(dirName); string newReldirname = sb.Replace(pn.Name, "", 0, pn.Name.Length).ToString(); // string newRelFilename = newReldirname + @"\" + typeSpecificFileName; string newdirname = pn.FolderObject + newReldirname; var file = new FileInfo(newdirname + @"\" + typeSpecificFileName); // FileInfo file = new FileInfo(dir.ToString() + @"\" + typeSpecificFileName); if (!file.Exists) { FileStream fs = file.Create(); fs.Close(); var fiNode = new FileNode(file); node.Nodes.Add(fiNode); node.Expanded = true; Novel8rProjectHandler.Instance.AddFile(newdirname + @"\" + typeSpecificFileName); fiNode.BeginEdit(); } else { MessageBox.Show("File already exists in folder", DialogHelper.Instance.GetApplicationName()); } } } }