© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
7 replies
Caedrius

Directory.Packages.props working for all projects except Api

I have the following Directory.Packages.props in my solution:
<Project>

    <ItemGroup Condition="$(MSBuildProjectname.EndsWith('Api'))">
        <PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2"/>
        <PackageVersion Include="Swashbuckle.AspNetCore.Swagger" Version="6.4.0"/>
    </ItemGroup>

    <ItemGroup Condition="$(MSBuildProjectName.EndsWith('BuildingBlocks.Domain'))">
        <PackageVersion Include="MediatR" Version="12.2.0" />
    </ItemGroup>

    <ItemGroup Condition="$(MSBuildProjectName.EndsWith('BuildingBlocks.Application'))">
        <PackageVersion Include="FluentValidation" Version="11.8.1" />
        <PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
    </ItemGroup>

    <ItemGroup Condition="$(MSBuildProjectName.EndsWith('BuildingBlocks.Infrastructure'))">
        <PackageVersion Include="Autofac" Version="7.1.0" />
        <PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
        <PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
        <PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
        <PackageVersion Include="Polly" Version="8.2.0" />
    </ItemGroup>

</Project>
<Project>

    <ItemGroup Condition="$(MSBuildProjectname.EndsWith('Api'))">
        <PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2"/>
        <PackageVersion Include="Swashbuckle.AspNetCore.Swagger" Version="6.4.0"/>
    </ItemGroup>

    <ItemGroup Condition="$(MSBuildProjectName.EndsWith('BuildingBlocks.Domain'))">
        <PackageVersion Include="MediatR" Version="12.2.0" />
    </ItemGroup>

    <ItemGroup Condition="$(MSBuildProjectName.EndsWith('BuildingBlocks.Application'))">
        <PackageVersion Include="FluentValidation" Version="11.8.1" />
        <PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
    </ItemGroup>

    <ItemGroup Condition="$(MSBuildProjectName.EndsWith('BuildingBlocks.Infrastructure'))">
        <PackageVersion Include="Autofac" Version="7.1.0" />
        <PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
        <PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
        <PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
        <PackageVersion Include="Polly" Version="8.2.0" />
    </ItemGroup>

</Project>


It works as expected for all projects in my solution expect my Api project. Any clues why?
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Updating packages in Directory.Packages.props
C#CC# / help
2y ago
❔ Directory.Packages.props Support Floating Versions
C#CC# / help
3y ago
Working with Directory.Build.props.
C#CC# / help
3y ago