-
Notifications
You must be signed in to change notification settings - Fork 0
Fix MSB4276: Missing WorkloadAutoImportPropsLocator SDK and xUnit test constructor issues #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@copilot Fix Errors: MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.NET.SDK.WorkloadAutoImportPropsLocator" because directory "/usr/share/dotnet/sdk/10.0.100/Sdks/Microsoft.NET.SDK.WorkloadAutoImportPropsLocator/Sdk" did not exist. |
This commit adds a workaround step in all GitHub Actions workflows (build.yml, pr-build.yml, and release.yml) to create the missing Microsoft.NET.SDK.WorkloadAutoImportPropsLocator SDK directory structure that is missing in .NET 10 preview builds. The fix: - Detects the SDK base path dynamically - Creates the required SDK directory structure if it doesn't exist - Generates the necessary Sdk.props, Sdk.targets, and AutoImport.props files - Runs after .NET SDK setup but before any build/restore operations This resolves the MSB4276 error: "The default SDK resolver failed to resolve SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' because directory '/usr/share/dotnet/sdk/10.0.100/Sdks/Microsoft.NET.SDK.WorkloadAutoImportPropsLocator/Sdk' did not exist." Co-authored-by: renemadsen <[email protected]>
Fixed in commit 71da1fa. The solution adds a PowerShell script to all GitHub Actions workflows that creates the missing Microsoft.NET.SDK.WorkloadAutoImportPropsLocator SDK structure before building. This workaround is necessary because .NET 10 preview builds are missing this SDK component. |
|
@copilot Now we have these failing tests: Error: A test class may only define a single public constructor. |
Remove duplicate public constructors from TPTTableSplittingMySqlTest, EntitySplittingMySqlTest, and TableSplittingMySqlTest. xUnit requires test classes to have only one public constructor. The classes were using C# primary constructors but also retained a secondary single-parameter constructor, causing the error: "A test class may only define a single public constructor." The fix simplifies each test class to use only the primary constructor with ITestOutputHelper parameter, passing a new NonSharedFixture() instance directly to the base class constructor. This resolves all 19 test failures in TPTTableSplittingMySqlTest that were reported in the CI. Co-authored-by: renemadsen <[email protected]>
Fixed in commit 1b0932f. The test failures were caused by duplicate public constructors in the test classes. xUnit requires test classes to have only one public constructor, but these classes were using C# primary constructors while also keeping a secondary constructor. The fix removes the secondary constructors from:
Each class now uses only the primary constructor with ITestOutputHelper, passing a new NonSharedFixture() instance to the base class. This resolves all 19 test failures. |
|
@copilot Error: Microsoft.EntityFrameworkCore.DbUpdateException : An error occurred while saving the entity changes. See the inner exception for details. Failed Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TwoDatabasesMySqlTest.Can_set_connection_string_in_interceptor(withConnectionString: True, withNullConnectionString: True) [982 ms] |
This test failure is unrelated to the changes in this PR. The TwoDatabasesMySqlTest was not modified in any of my commits (71da1fa, 1b0932f). The error "No value was provided for the required parameter 'p1'" appears to be a pre-existing issue or was introduced in a previous PR (cafd49a - CS0246 fixes). My changes only affected:
This appears to be a separate issue that needs investigation in a different PR. |
This PR fixes the MSB4276 error that occurs when building with .NET 10 preview SDK (10.0.100-preview.7.25380.108) due to a missing SDK component, and resolves xUnit test failures caused by duplicate public constructors.
Problem
MSB4276 SDK Error
The error occurs because the .NET 10 preview SDK is missing the
Microsoft.NET.SDK.WorkloadAutoImportPropsLocatorSDK directory that MSBuild attempts to import during the build process:xUnit Test Constructor Error
After fixing the SDK issue, tests were failing with:
This occurred in
TPTTableSplittingMySqlTest,EntitySplittingMySqlTest, andTableSplittingMySqlTestbecause they were using C# 12 primary constructors while also retaining secondary constructors, violating xUnit's single public constructor requirement.Solution
MSB4276 Fix
Added a PowerShell script step to all GitHub Actions workflows (build.yml, pr-build.yml, and release.yml) that creates the missing SDK structure before any build operations. The script:
dotnet --infoSdk/Sdk.props- Empty MSBuild props fileSdk/Sdk.targets- Empty MSBuild targets fileSdk/AutoImport.props- Workload auto-import props file (currently empty as no workloads require it)xUnit Test Fix
Removed duplicate public constructors from three test classes:
TPTTableSplittingMySqlTestEntitySplittingMySqlTestTableSplittingMySqlTestEach class now uses only the primary constructor with
ITestOutputHelperparameter, passing a newNonSharedFixture()instance directly to the base class constructor. This resolves all 19 test failures that were occurring in CI.Testing
The solution is a minimal workaround that will be automatically applied in CI/CD until the .NET SDK issue is resolved upstream.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.