"Undefined" - Build.Evaluation.ProjectProperty

Issue #7 resolved
Denis Kuzmin repo owner created an issue

problem with the _reloadProjectCollection() on some projects

+ [203] "DevEnvDir"="*Undefined*" ["*Undefined*"]   Microsoft.Build.Evaluation.ProjectProperty {Microsoft.Build.Evaluation.ProjectProperty.ProjectPropertyXmlBacked}
+ [204] "SolutionName"="*Undefined*" ["*Undefined*"]    Microsoft.Build.Evaluation.ProjectProperty {Microsoft.Build.Evaluation.ProjectProperty.ProjectPropertyXmlBacked}
+ [205] "SolutionFileName"="*Undefined*" ["*Undefined*"]    Microsoft.Build.Evaluation.ProjectProperty {Microsoft.Build.Evaluation.ProjectProperty.ProjectPropertyXmlBacked}
+ [206] "SolutionPath"="*Undefined*" ["*Undefined*"]    Microsoft.Build.Evaluation.ProjectProperty {Microsoft.Build.Evaluation.ProjectProperty.ProjectPropertyXmlBacked}
+ [207] "SolutionDir"="*Undefined*" ["*Undefined*"] Microsoft.Build.Evaluation.ProjectProperty {Microsoft.Build.Evaluation.ProjectProperty.ProjectPropertyXmlBacked}
+ [208] "SolutionExt"="*Undefined*" ["*Undefined*"] Microsoft.Build.Evaluation.ProjectProperty {Microsoft.Build.Evaluation.ProjectProperty.ProjectPropertyXmlBacked}

The "Undefined" can occur when GlobalProjectCollection can filled with the LoadProject instead of a Solution-context.

all problems(similar) come from GlobalProjectCollection (Microsoft.Build.Evaluation)

MSDN:

see #8

Comments (4)

  1. Denis Kuzmin reporter

    we have the next list of properties with problems after manually loading in GlobalProjectCollection:

    +  [0]    {[BuildingInsideVisualStudio, true]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [1]    {[DevEnvDir, C:\Program Files %28x86%29\Microsoft Visual Studio 10.0\Common7\IDE\]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [2]    {[SolutionExt, .sln]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [3]    {[SolutionName, libraryLite]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [4]    {[SolutionFileName, libraryLite.sln]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [5]    {[SolutionPath, D:\prg\projects\libraryLite\old_platform\libraryLite\libraryLite.sln]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [6]    {[SolutionDir, D:\prg\projects\libraryLite\old_platform\libraryLite\]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [7]    {[VisualStudioVersion, 10.0]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [8]    {[RunCodeAnalysisOnce, FALSE]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [9]    {[Configuration, Release]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [10]    {[Platform, x86]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [11]    {[CurrentSolutionConfigurationContents, <SolutionConfiguration>
    <ProjectConfiguration Project="{269bdf2d-6228-44db-8685-48b65db63069}" AbsolutePath="D:\prg\projects\libraryLite\old_platform\libraryLite\libraryLite\libraryLite.csproj">Release|x86</ProjectConfiguration>
    </SolutionConfiguration>]}    System.Collections.Generic.KeyValuePair<string,string>
    +  [12]    {[VSIDEResolvedNonMSBuildProjectOutputs, <VSIDEResolvedNonMSBuildProjectOutputs />]}    System.Collections.Generic.KeyValuePair<string,string>
    

    because the GlobalProperties of GlobalProjectCollection can be is empty

    So, we have the next places where we can override this values:

    * BuildingInsideVisualStudio             :: ?
    * DevEnvDir                              :: IVsShell.GetProperty
    * SolutionExt                            :: IVsSolution.GetSolutionInfo or Microsoft.Build.BuildEngine.Project.PropertyGroups
    * SolutionName                           :: IVsSolution.GetSolutionInfo or Microsoft.Build.BuildEngine.Project.PropertyGroups
    * SolutionFileName                       :: IVsSolution.GetSolutionInfo or Microsoft.Build.BuildEngine.Project.PropertyGroups
    * SolutionPath                           :: IVsSolution.GetSolutionInfo or Microsoft.Build.BuildEngine.Project.PropertyGroups
    * SolutionDir                            :: IVsSolution.GetSolutionInfo or Microsoft.Build.BuildEngine.Project.PropertyGroups
    * VisualStudioVersion                    :: Microsoft.Build.Execution.ProjectPropertyInstance -> ProjectCollection.GlobalProjectCollection.EnvironmentProperties
    * RunCodeAnalysisOnce                    :: ?
    * Configuration                          :: Solution.SolutionBuild.ActiveConfiguration.SolutionContexts
    * Platform                               :: Solution.SolutionBuild.ActiveConfiguration.SolutionContexts
    * CurrentSolutionConfigurationContents   :: ProjectCollection.GlobalProjectCollection.GlobalProperties
    * VSIDEResolvedNonMSBuildProjectOutputs  :: ProjectCollection.GlobalProjectCollection.GlobalProperties
    

    e.g.:

    Dictionary<string, string> prop = new Dictionary<string, string>();
    prop["Configuration"]   = sln.ConfigurationName;
    prop["Platform"]        = sln.PlatformName;
    ...
    new Microsoft.Build.Evaluation.Project(<projectFile>, prop, null, ProjectCollection.GlobalProjectCollection);
    ...
    sln - > Dte2.Solution.FullName
    

    note: Microsoft.Build.BuildEngine.Project - has been deprecated and need to use the Microsoft.Build.Evaluation.Project

    http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.project%28v=vs.121%29.aspx

    then we can use Microsoft.VisualStudio.Shell.Interop.IVsSolution.GetSolutionInfo

    map of GlobalProperty in StructuresEnums.cs:

    // Copyright (c) Microsoft Corporation. All rights reserved.
    // This code is licensed under the Visual Studio SDK license terms.
    // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
    // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
    // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
    // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
    ...
    
    namespace Microsoft.VisualStudio.Project
    {
    ...
        public enum GlobalProperty
        {
            /// <summary>
            /// Property specifying that we are building inside VS.
            /// </summary>
            BuildingInsideVisualStudio,
    
            /// <summary>
            /// The VS installation directory. This is the same as the $(DevEnvDir) macro.
            /// </summary>
            [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Env")]
            DevEnvDir,
    
            /// <summary>
            /// The name of the solution the project is created. This is the same as the $(SolutionName) macro.
            /// </summary>
            SolutionName,
    
            /// <summary>
            /// The file name of the solution. This is the same as $(SolutionFileName) macro.
            /// </summary>
            SolutionFileName,
    
            /// <summary>
            /// The full path of the solution. This is the same as the $(SolutionPath) macro.
            /// </summary>
            SolutionPath,
    
            /// <summary>
            /// The directory of the solution. This is the same as the $(SolutionDir) macro.
            /// </summary>              
            SolutionDir,
    
            /// <summary>
            /// The extension of teh directory. This is the same as the $(SolutionExt) macro.
            /// </summary>
            SolutionExt,
    
            /// <summary>
            /// The fxcop installation directory.
            /// </summary>
            FxCopDir,
    
            /// <summary>
            /// The ResolvedNonMSBuildProjectOutputs msbuild property
            /// </summary>
            [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "VSIDE")]
            VSIDEResolvedNonMSBuildProjectOutputs,
    
            /// <summary>
            /// The Configuartion property.
            /// </summary>
            Configuration,
    
            /// <summary>
            /// The platform property.
            /// </summary>
            Platform,
    
            /// <summary>
            /// The RunCodeAnalysisOnce property
            /// </summary>
            RunCodeAnalysisOnce,
    
            /// <summary>
            /// The VisualStudioStyleErrors property
            /// </summary>
            VisualStudioStyleErrors,
        }
    ...
    

    + ProjectNode.cs

    ambiguousness with the:

    • BuildingInsideVisualStudio - by default(can be changed in other components) set as "true" in Microsoft.VisualStudio.Project.ProjectNode :: DoMSBuildSubmission & SetupProjectGlobalPropertiesThatAllProjectSystemsMustSet
    • RunCodeAnalysisOnce - by default set as "false" in Microsoft.VisualStudio.Package.GlobalPropertyHandler
  2. Log in to comment