Beispiel #1
0
        private static IVsBuildPropertyStorage GetPropertyStorage(Project project)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsHierarchy projectHierarchy = project.GetVsHierarchy();

            return(GetPropertyStorage(projectHierarchy));
        }
Beispiel #2
0
 public static bool IsCsOrVbProject(Project project)
 {
     project.GetItemInfo(out IVsHierarchy hierarchy, out _, out _);
     return(hierarchy.IsCapabilityMatch("CSharp") || hierarchy.IsCapabilityMatch("VB"));
 }
Beispiel #3
0
        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;
            }
        }
Beispiel #4
0
        public static async Task <DocumentView> ActivateTextDocumentAsync(Project prj, string fileName)
        {
            var documentView = await VS.Documents.OpenAsync(fileName);

            return(documentView);
        }