GetEvaluatedMetaData Problem

Hi,

I am attempting to get the full path of a build item as follows:

string fullPath = buildItem.GetEvaluatedMetaData("FullPath");

But if my project path is C:\Projects\Project for example this method is (for a source file called file.cs) returning:

C:\Projects\Project\bin\file.cs

It should be

C:\Projects\Project\file.cs

Why is it adding bin to the path If FullPath is not the correct metadata item to use, what is Is there a complete listing of metadata used by Visual Studio/MSBuild documented anywhere

Kind Regards




Answer this question

GetEvaluatedMetaData Problem

  • lode

    Are you hosting MSBuild engine in you process In that case the problem maybe that you need to set the current working directory for the process to the main project directory before calling this method. The full path is always computed with respect to current working directory (and yes we are working to fix that).

    Thanks,

    Vladimir



  • Walter Sagesser

    Hi,
    I'm not sure why you're path is incorrect, you're using the correct metadata. I've never had a problem with using the GetEvaluatedMetadata("FullPath") expression. Are you sure that a file 'C:\Projects\Project\bin\file.cs' doesn't exist
    As for where can you find a complete listing of metadata. There are 2 kinds of metadata, well known metadata and custom metadata. Custom metadata is metadata that is attached to the item by either the project or your app. You can get the complete list of well known metadata at:
    http://msdn2.microsoft.com/en-us/library/ms164313.aspx

    Sayed Ibrahim Hashimi
    www.sedodream.com

  • Nick Porter

    hi,

    I tried setting the current directory to the main project directory and tried to find the full path. My code basically is as follows,

    Directory.SetCurrentDirectory(Path.GetDirectoryName(projectPath));

    BuildItemGroup group = project.GetEvaluatedItemsByName("Reference");

    foreach (BuildItem item in group)

    {

    string refPath=item.GetEvaluatedMetadata("FullPath");

    Console.WriteLine(refPath);

    }

    Still I do not get any sensible value for refPath. For example if I am running this code against C:\Projects\MyProject.csproj and I have reference to System.dll in my project. From this I get output like C:\Projects\MyProject\System which makes no sense and also hint path gives something like ..\..\..\..\windows\complus\v1.x8rret\System.dll which again I am unable to make any sense of. Is there anything I did wrong I hope to get solution to this problem soon.

    Thanks,

    Nush


  • hwage

    Hi Sayed,

    Thanks for the reply. I am 199% positive that no source exists in the bin path. BTW and notwithstanding that my sample code was C#, the project I am actually having a problem with is a VB.NET project, so maybe it is a language specific issue. Thanks for the link re well-known metadata.

    As an off-topic aside, I don't know whether it is an IE7 feature or not, but entire sections of these forums and the MSDN are rendered with almost microscopic and certainly unreadable font - what is going on

    Kind Regards



  • GetEvaluatedMetaData Problem