a0351803 chore(dotnet): add analyzer smoke tests that run real MSBuild evaluation
Every existing test hands BuildTargets a hand-built property dictionary, so it
can only assert what the author believed MSBuild evaluates. That seam has now
produced three defects: the ApiDescription package defaulting
OpenApiDocumentsDirectory to $(BaseIntermediateOutputPath), artifacts fixtures
setting UseArtifactsOutput with no BaseOutputPath, and PackageOutputPath always
being set to a Debug path pack never writes to.
Run the analyzer the way the plugin does instead - as a process, over a real
csproj in a temp workspace, with MSBuild doing the evaluation - and assert the
targets it emits. Out of process because the analyzer registers MSBuildLocator
itself; registering in the test host would fight the runner over which MSBuild
assemblies load. Both MsbuildAnalyzer.dll and its runtimeconfig.json land beside
the test assembly via the project reference, so AppContext.BaseDirectory locates
it with no path arithmetic.
Four cases, ~270ms each: default bin/obj, the OpenAPI document globs, the pack
release directory, and an artifacts project renamed for Nx. Deliberately few -
each pays for a process launch and a full evaluation. 983ac218 chore(dotnet): add analyzer smoke tests that run real MSBuild evaluation
Every existing test hands BuildTargets a hand-built property dictionary, so it
can only assert what the author believed MSBuild evaluates. That seam has now
produced three defects: the ApiDescription package defaulting
OpenApiDocumentsDirectory to $(BaseIntermediateOutputPath), artifacts fixtures
setting UseArtifactsOutput with no BaseOutputPath, and PackageOutputPath always
being set to a Debug path pack never writes to.
Run the analyzer the way the plugin does instead - as a process, over a real
csproj in a temp workspace, with MSBuild doing the evaluation - and assert the
targets it emits. Out of process because the analyzer registers MSBuildLocator
itself; registering in the test host would fight the runner over which MSBuild
assemblies load. Both MsbuildAnalyzer.dll and its runtimeconfig.json land beside
the test assembly via the project reference, so AppContext.BaseDirectory locates
it with no path arithmetic.
Four cases, ~270ms each: default bin/obj, the OpenAPI document globs, the pack
release directory, and an artifacts project renamed for Nx. Deliberately few -
each pays for a process launch and a full evaluation. 33fda87c chore(dotnet): add analyzer smoke tests that run real MSBuild evaluation
Every existing test hands BuildTargets a hand-built property dictionary, so it
can only assert what the author believed MSBuild evaluates. That seam has now
produced three defects: the ApiDescription package defaulting
OpenApiDocumentsDirectory to $(BaseIntermediateOutputPath), artifacts fixtures
setting UseArtifactsOutput with no BaseOutputPath, and PackageOutputPath always
being set to a Debug path pack never writes to.
Run the analyzer the way the plugin does instead - as a process, over a real
csproj in a temp workspace, with MSBuild doing the evaluation - and assert the
targets it emits. Out of process because the analyzer registers MSBuildLocator
itself; registering in the test host would fight the runner over which MSBuild
assemblies load. Both MsbuildAnalyzer.dll and its runtimeconfig.json land beside
the test assembly via the project reference, so AppContext.BaseDirectory locates
it with no path arithmetic.
Four cases, ~270ms each: default bin/obj, the OpenAPI document globs, the pack
release directory, and an artifacts project renamed for Nx. Deliberately few -
each pays for a process launch and a full evaluation. b67e6182 chore(dotnet): add analyzer smoke tests that run real MSBuild evaluation
Every existing test hands BuildTargets a hand-built property dictionary, so it
can only assert what the author believed MSBuild evaluates. That seam has now
produced three defects: the ApiDescription package defaulting
OpenApiDocumentsDirectory to $(BaseIntermediateOutputPath), artifacts fixtures
setting UseArtifactsOutput with no BaseOutputPath, and PackageOutputPath always
being set to a Debug path pack never writes to.
Run the analyzer the way the plugin does instead - as a process, over a real
csproj in a temp workspace, with MSBuild doing the evaluation - and assert the
targets it emits. Out of process because the analyzer registers MSBuildLocator
itself; registering in the test host would fight the runner over which MSBuild
assemblies load. Both MsbuildAnalyzer.dll and its runtimeconfig.json land beside
the test assembly via the project reference, so AppContext.BaseDirectory locates
it with no path arithmetic.
Four cases, ~270ms each: default bin/obj, the OpenAPI document globs, the pack
release directory, and an artifacts project renamed for Nx. Deliberately few -
each pays for a process launch and a full evaluation. 6fe8ce04 fix(dotnet): derive artifacts output paths from MSBuild, not hardcoded names
Under UseArtifactsOutput the analyzer rebuilt each output path from string
literals - artifacts/bin/<name>, artifacts/publish/<name>, artifacts/package -
using the Nx project name. Every one of those segments is wrong under
configuration the SDK supports:
- ArtifactsProjectName defaults to MSBuildProjectName, never the Nx name. A
project renamed via <Nx><Name> declared artifacts/bin/<nx-name> while the
build wrote artifacts/bin/<csproj-name>, so nothing was cached or restored.
- ArtifactsBinOutputName, ArtifactsPublishOutputName and
ArtifactsPackageOutputName are all overridable and were ignored.
MSBuild already computes these. BaseOutputPath and BaseIntermediateOutputPath
are always set under the artifacts layout and are pivot-free, which is exactly
the parent-of-all-configurations the hardcoded paths were approximating, so
both special cases are deleted and the existing branches handle it.
Publish and pack keep a constructed path because PublishDir and
PackageOutputPath carry the pivot segment, which is per-configuration; they
now build it from the evaluated names instead of literals.
Verified with `dotnet msbuild -getProperty:` on a real artifacts-layout
project: a <Nx><Name> rename leaves BaseOutputPath at artifacts/bin/Renamed,
and setting ArtifactsProjectName plus ArtifactsBinOutputName moves it to
artifacts/binaries/custom-name.
The artifacts test fixtures asserted a state MSBuild never produces -
UseArtifactsOutput set with no BaseOutputPath - so they are rebuilt from
measured values. 6fe8ce04 fix(dotnet): derive artifacts output paths from MSBuild, not hardcoded names
Under UseArtifactsOutput the analyzer rebuilt each output path from string
literals - artifacts/bin/<name>, artifacts/publish/<name>, artifacts/package -
using the Nx project name. Every one of those segments is wrong under
configuration the SDK supports:
- ArtifactsProjectName defaults to MSBuildProjectName, never the Nx name. A
project renamed via <Nx><Name> declared artifacts/bin/<nx-name> while the
build wrote artifacts/bin/<csproj-name>, so nothing was cached or restored.
- ArtifactsBinOutputName, ArtifactsPublishOutputName and
ArtifactsPackageOutputName are all overridable and were ignored.
MSBuild already computes these. BaseOutputPath and BaseIntermediateOutputPath
are always set under the artifacts layout and are pivot-free, which is exactly
the parent-of-all-configurations the hardcoded paths were approximating, so
both special cases are deleted and the existing branches handle it.
Publish and pack keep a constructed path because PublishDir and
PackageOutputPath carry the pivot segment, which is per-configuration; they
now build it from the evaluated names instead of literals.
Verified with `dotnet msbuild -getProperty:` on a real artifacts-layout
project: a <Nx><Name> rename leaves BaseOutputPath at artifacts/bin/Renamed,
and setting ArtifactsProjectName plus ArtifactsBinOutputName moves it to
artifacts/binaries/custom-name.
The artifacts test fixtures asserted a state MSBuild never produces -
UseArtifactsOutput set with no BaseOutputPath - so they are rebuilt from
measured values.