Skip to content

9.2: Have to add <IsAspireHost>false</IsAspireHost> to test project #8629

@afscrome

Description

@afscrome

After upgrading my test project from 9.1 to 9.2, my test project refused to compile with the following error:

The type or namespace name 'ABC' does not exist in the namespace 'XYZ' (are you missing an assembly reference?)

Looking in the logs, I had a bunch of warnings of the following

'..\MY.INTEGRATION\MY.INTEGRATION.csproj' is referenced by an Aspire Host project, but it is not an executable. Did you mean to set IsAspireProjectResource="false"?

To fix this, I had to explicitly add <IsAspireHost>false</IsAspireHost> into my project - presumably a side effect of #8144 .

  1. Can the SDK not automatically set IsAspireHost for a test project?
  2. If not, does this need to be highlighted in the upgrade docs that tests may now need to explicitly set <IsAspireHost>false</IsAspireHost>.

For reference, here is my test csproj.

<Project Sdk="Microsoft.NET.Sdk">

    <Sdk Name="Aspire.AppHost.Sdk" Version="9.1.0" />
    <!--<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0-preview.1.25205.2" />-->
    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <IsPackable>false</IsPackable>
        <IsTestProject>true</IsTestProject>
        <!-- Have to add the following with 9.2 -->
        <!--<IsAspireHost>false</IsAspireHost> -->
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Aspire.Hosting.AppHost" />
        <PackageReference Include="Aspire.Hosting.Testing" />
        <PackageReference Include="coverlet.collector">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Extensions.Logging.NUnit" />
        <PackageReference Include="Microsoft.NET.Test.Sdk" />
        <PackageReference Include="NUnit" />
        <PackageReference Include="NUnit.Analyzers">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="NUnit3TestAdapter" />
        <PackageReference Include="prometheus-net.AspNetCore" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\MYINTEGRATION\MY.INTEGRATION.csproj" />
      <!-- … Several more project references ... -->
    </ItemGroup>

    <ItemGroup>
        <Using Include="System.Net" />
        <Using Include="Microsoft.Extensions.DependencyInjection" />
        <Using Include="Aspire.Hosting.ApplicationModel" />
        <Using Include="Aspire.Hosting.Testing" />
        <Using Include="NUnit.Framework" />
    </ItemGroup>

</Project>

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions