Skip to content

dotnet publish to folder for Aspire.Hosting.Testing projects #6857

@Culan

Description

@Culan

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

In our build pipeline we have separated the build from the test execution to enable all our test projects run in parallel on multiple test agents.

To accomplish this we have this workflow:

  • dotnet build the solution
  • dotnet publish each of the test projects with the --no-build option
  • store the output of the publish
  • check and react to any build warnings (here the building of the full solution helps because we also have some sample projects so this will cover all for us)

If this is fine we move to the test stage where we:

  • For every test project allocate one of the test agents.
  • Download the artifact from previous step
  • Execute the tests

Obviously we want only one build to happen and we want our tests run on that particular build so to save time and space, the test agent doesn't even have to clone the repo, it just gets everything from the dotnet publish and then executes dotnet test on that dll.

When we try to apply the same to Aspire.Hosting.Testing test projects the publish seems to succeed but then when we run the tests we are hitting a DirectoryNotFoundException with an directory hinting of the agent who build it.

[xUnit.net 00:00:41.49] System.IO.DirectoryNotFoundException : E:\home\vsts\work\1\s\Source\Gateway.AppHost\ [xUnit.net 00:00:41.49] Stack Trace: [xUnit.net 00:00:41.49] at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters) [xUnit.net 00:00:41.49] at Microsoft.Extensions.Hosting.HostBuilder.CreateHostingEnvironment(IConfiguration hostConfiguration) [xUnit.net 00:00:41.49] at Microsoft.Extensions.Hosting.HostApplicationBuilder.Initialize(HostApplicationBuilderSettings settings, HostBuilderContext& hostBuilderContext, IHostEnvironment& environment, LoggingBuilder& logging, MetricsBuilder& metrics) [xUnit.net 00:00:41.49] at Microsoft.Extensions.Hosting.HostApplicationBuilder..ctor(HostApplicationBuilderSettings settings) [xUnit.net 00:00:41.49] /_/src/Aspire.Hosting/DistributedApplicationBuilder.cs(132,0): at Aspire.Hosting.DistributedApplicationBuilder..ctor(DistributedApplicationOptions options) [xUnit.net 00:00:41.49] /_/src/Aspire.Hosting/DistributedApplication.cs(141,0): at Aspire.Hosting.DistributedApplication.CreateBuilder(String[] args) [xUnit.net 00:00:41.49] /_/Source/Gateway.AppHost/Program.cs(5,0): at Program.<Main>$(String[] args) [xUnit.net 00:00:41.49] at Program.<Main>(String[] args)

I've researched current issues there is none pointing exactly to my use-case but i found some hints:
#1704 - Here DamianEdwards is saying that during compile time the path to DCP from the AssemblyMetadata attributes stamped onto the AppHost

So i had a quick check on my apphost:

AssemblyMetadataAttribute: dcpclipath value: /home/vsts/.nuget/packages/aspire.hosting.orchestration.linux-x64/9.0.0/tools/dcp
AssemblyMetadataAttribute: dcpextensionpaths value: /home/vsts/.nuget/packages/aspire.hosting.orchestration.linux-x64/9.0.0/tools/ext/
AssemblyMetadataAttribute: dcpbinpath value: /home/vsts/.nuget/packages/aspire.hosting.orchestration.linux-x64/9.0.0/tools/ext/bin/
AssemblyMetadataAttribute: apphostprojectpath value: /home/vsts/work/1/s/Source/Gateway.AppHost
AssemblyMetadataAttribute: apphostprojectname value: Gateway.AppHost.csproj
AssemblyMetadataAttribute: aspiredashboardpath value: /home/vsts/.nuget/packages/aspire.dashboard.sdk.linux-x64/9.0.0/tools/Aspire.Dashboard

Here we can see references to the build host's nuget cache and the sourcecode.

I guess that what i'm after is a dotnet publish to folder functionality that would remove any link towards the sourcecode and the build host.

Describe the solution you'd like

dotnet publish to folder that creates a package that can run independently.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-testingIssues pertaining to the APIs in Aspire.Hosting.Testing

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions