Repository navigation
chore: Modify csproj-based project build logics - #3235
Conversation
|
I've re-enable Because it cause following errors for
It seems occurred because |
|
Wasm related CI tests are still failed when using |
|
It seems that xUnit v2 is incompatible with wasm. It's probably fixed by #3232. |
This issue is caused commit 7f18102 is not pushed to target CI branch. And I've added following commits to avoid issue when using |
20fc0fe to
75973bf
Compare
|
By changing some settings. CI: https://github.com/filzrev/BenchmarkDotNet/actions/runs/32571372114/workflow |
Output paths: - --no-dependencies was widened to every autogenerated build via a filename check. The generated project keeps its ProjectReference, and RIDs propagate to exe references but not library ones, so the reference resolved to a RID-specific ref assembly that nothing produced. Reverted to the ForcedNoDependenciesForIntegrationTests gate. - GetPublishDirectoryPath defaulted to <artifacts>/publish while the generators expect the executable in their binaries directory. That was masked while --output overrode PublishDir on the command line; once PublishDir became authoritative, publish wrote where BenchmarkDotNet never looks. - OutputPath was derived by chopping TFM.Length + 1 characters off the binaries path, which is wrong wherever that path ends in the RID. The generated project sets AppendTargetFrameworkToOutputPath=false instead. - The generated project sets OutDir as well as OutputPath. OutDir only falls back to OutputPath when it has not been set, so a Directory.Build.props in the benchmark project's tree that sets OutDir kept it, and the build went somewhere BenchmarkDotNet does not look. The command line arguments this replaces set both, which is why the case did not arise before. Reference gathering: The gatherer globbed *.dll out of the benchmark project's output, which holds more than references: content files copied there, and native libraries. A native library handed to MSBuild as an assembly is MSB3246. A content file is published by the ProjectReference already, so referencing it too puts the same file in the publish set twice, and crossgen2 rejects duplicate inputs - the NETSDK1152 that R2R and Wasm were suppressing. And an exe project has no dll beside its exe, so on .NET Framework the benchmark assembly was never gathered at all. Asking MSBuild for @(ReferencePath) avoids all three, so both suppressions go. It also built DllGatherer.csproj, a copy of the generated project made from the default template, which could not match what a toolchain had actually generated. The gathering pass now builds the generated project itself with SkipCompilerExecution, so it stops once MSBuild has resolved the references and needs neither a second project, a stub entry point, nor the output-path handshake between the two. Not running the compiler also keeps the pass from writing a program built against incomplete references into the directory BenchmarkDotNet reads the benchmark executable from. The gathering pass no longer edits the project it just built either. It writes what MSBuild resolved beside the project, and the project imports that file when it exists, so the project is complete the moment it is written. NativeAot passed -r on the command line while its project already declared the RuntimeIdentifier. Only the command line one reaches the referenced projects, so the benchmark project was built once for gathering and again for the real build, into two different pivots, and the references gathered came from the pivot that was not used. Project generation: The generated project is composed as an XDocument rather than substituted into a text template, so a path holding an XML character cannot corrupt it, and a toolchain extends it by overriding AddEarlyProperties, AddProjectContent or AddLateProperties instead of maintaining a near-copy of the whole file. R2R, Wasm and NativeAot each kept their own template that had drifted from the default one; they now share the parts they never meant to differ on, which is also what puts the gathered references in front of all four toolchains rather than only the default one. That leaves nothing importing BenchmarkDotNet.Build.props or .targets, so those and the three csproj templates are gone, along with the GenerateCustomBuildHooksAsync hook added to write them. Build invocations: Publishing ran as three dotnet invocations - restore, then build, then publish - when the publish command performs all three itself, so that step is one invocation now. Restoring separately is still what the gathering pass does, and what a toolchain that only builds does, since those are the passes that have to do the restoring. A custom build configuration takes a single invocation as well, a standalone restore having no way to be told which configuration to use. Building without dependencies now covers the publishing toolchains too. That is only safe because no toolchain passes a runtime identifier on the command line any more, where it is a global property and reaches the referenced projects: a library has no runtime identifier to resolve against, and not building it is what stops the sdk from negotiating one away. Mono was the last to do so and declares SelfContained and the identifier in the project instead, which leaves MonoPublisher with nothing to do and the helper that built NativeAot's argument with no callers. Publishing with --no-build is what raised NETSDK1085 on Wasm, and nothing passes it any more, so that project no longer turns BuildProjectReferences off to suppress it. SDK requirement: ArtifactsPath is set as a property rather than passed as --artifacts-path, which is a .NET 8 SDK argument. An older SDK errors on the argument but ignores the property, so nothing has to require that SDK: master's fallback of building net7 and earlier one partition at a time already covers the isolation those builds then go without. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@filzrev I put up a PR against this branch. filzrev#16 |
|
@timcassell |
Fix the csproj build plumbing's output paths and reference gathering
This PR intended to fix #3191.
What's changed in this PR
1. Cherry picks other PR commits
Following PR contents are included
2. Remove DllGatherer related logics
After this PR changes, DllGatherer logics seems not be needed.
So I've removed DllGatherer related logics.
3. Add settings for Autogenerated project.
Modify
BenchmarkDotNet.Build.props.txttemplate.And enable following settings for Autogenerated project.
OutputPathPublishDir4. Cleanup
DotNetCliCommand.cslogics.Previously,
--outputand-p:PublishDircommand line parameters are used.These settings are handled as MSBuild Global property and that causing DoubleWrite Issues.
So this PR move these settings to Autogenerated.csproj level.
other projects build outputs are placed under
.artifactsdirectory.4. Other Changes
ErrorOnDuplicatePublishOutputFilessettings.XmlDocument.SaveAsynchelper method for netstandard2.0Test
Setting
ForcedNoDependenciesForIntegrationTests: falseversion of CI. (InProgress)