ProjectItems GetItemCollection(string fileName) { string relPath = ExtendedPath.GetRelativePath(this.projPath, fileName); var dteProj = project.DteProject(); ProjectItems result = dteProj.ProjectItems; if (relPath.IndexOf(":\\") > -1) { return(result); } string[] splittedName = relPath.Split(new char[] { '\\' }); for (int i = 0; i < splittedName.Length - 1; i++) { string name = splittedName[i]; ProjectItem pi = result.Item(name); if (pi != null) { result = pi.ProjectItems; } else { break; } } return(result); }
public ProjectDescription(Project project) { this.solution = (Solution)project.Parent; this.project = project; ThreadHelper.ThrowIfNotOnUIThread(); var dteProj = project.DteProject(); EnvDTE.Configuration conf = dteProj.ConfigurationManager.ActiveConfiguration; //foreach (Property item in conf.Properties) //{ // SD.Debug.WriteLine( $"{item.Name} = {item.Value}" ); //} // Get the MSBuild property storage IVsBuildPropertyStorage propertyStorage = GetPropertyStorage(project); try { this.platformTarget = (string)conf.Properties.Item("PlatformTarget").Value; } catch { } try { this.targetFramework = (string)dteProj.Properties.Item("TargetFrameworkMoniker").Value; } catch { } string outputPath = (string)conf.Properties.Item("OutputPath").Value; string fullPath = dteProj.Properties.Item("FullPath").Value as string; string outputFileName = GetBuildProperty(propertyStorage, "TargetFileName"); if (String.IsNullOrEmpty(outputFileName)) { int outputType = (int)dteProj.Properties.Item("OutputType").Value; // .NET Core Executables are dlls. if (this.targetFramework.StartsWith(".NETCoreApp")) { outputType = 2; } outputFileName = (string)dteProj.Properties.Item("AssemblyName").Value + (outputType == 2 ? ".dll" : ".exe"); } if (project.GetVsHierarchy().IsCapabilityMatch("CPS")) { // new .csproj format objPath = GetBuildProperty(propertyStorage, "IntermediateOutputPath"); string configuration = GetBuildProperty(propertyStorage, "Configuration"); debug = configuration == "Debug"; } else { // old .csproj format string debugInfo = (string)conf.Properties.Item("DebugInfo").Value; debug = debugInfo == "full"; objPath = (string)conf.Properties.Item("IntermediatePath").Value; } binFile = Path.Combine(fullPath, outputPath); binFile = Path.Combine(binFile, outputFileName); projPath = Path.GetDirectoryName(dteProj.FileName) + "\\"; string sign = GetBuildProperty(propertyStorage, "SignAssembly"); if (!String.IsNullOrEmpty(sign) && String.Compare(sign, "true", true) == 0) { keyFile = GetBuildProperty(propertyStorage, "AssemblyOriginatorKeyFile"); } else { keyFile = null; } }