Skip to content

Microsoft.AspNetCore.Mvc.Testing failed to build with error MSB4186 #42772

@ascentis-kelvingo

Description

@ascentis-kelvingo

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Having issue with the latest Microsoft.AspNetCore.Mvc.Testing with version 6.0.7 in the integration tests project.

This is my project structure.
image

This is the .csproj of the integration tests project.
image

I'm getting the MSB4186 error when I tried to build the integration tests project, I'm able to run the web app project directly without issue but not the integration test project.
image

4>C:\xxx\.nuget\packages\microsoft.aspnetcore.mvc.testing\6.0.7\build\net6.0\Microsoft.AspNetCore.Mvc.Testing.targets(34,9): error MSB4186: Invalid static method invocation syntax: "[System.IO.Path]::GetDirectoryName(C:\xxx\src\Template.Project.Core\Template.Project.Core.csproj)". Method 'System.IO.Path.GetDirectoryName' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order.

According to #31066, I tried to remove the condition in the targets but the project still failed to build.

Expected Behavior

The project is built successfully.

Steps To Reproduce

  1. Create a net6.0 class library with the name Template.Project.Core.
  2. Create a net6.0 class library with the name Template.Project.Infrastructure.
  3. Create a net6.0 ASP.Net Core Web App (MVC) with the name Template.Project.WebApp.
  4. Create a net6.0 NUnit Test Project with the name Template.Project.IntegrationTests.
  5. Follow the instruction in https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-6.0#aspnet-core-integration-tests.
  6. Build the integration tests project.
UPDATE 1

Rename the parent level folder to include ), the issue occurs when the full path contains ).

Exceptions (if any)

No response

.NET Version

6.0.302

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions