Saeid Mirzaei
Saeid Mirzaei

Reputation: 1236

Visual Studio Error : Unrecognized Guid format

I have a solution containing CSharp projects and Python projects in a specific folder.

I just added a Directory.Build.targets into the root of the folder as following:

<Project>
    <ItemGroup>
        <ProjectReference Include="..\..\Shared.csproj" />
    </ItemGroup>
    
    <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Debug'">
        ... commands
    </Target>
</Project>

After that, when I'm running the VisualStudio again in the output I have some errors because of Python projects:

..[path][projectName].pyproj : error : Unrecognized Guid format.

Any idea how can I exclude the python projects from the Directory.Build.targets?

Upvotes: 3

Views: 892

Answers (1)

PMF
PMF

Reputation: 17185

Yes. Add a condition, such as

    <ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
        <ProjectReference Include="..\..\Shared.csproj" />
    </ItemGroup>

This will include this group (in this case with a reference) only if the current project is a C# project.

Upvotes: 3

Related Questions