Skip to content

Update E2E WebApplication templates to fix tests errors in project creation - #7208

Merged
martinrrm merged 6 commits into
devfrom
dev-martinrrm-fix-e2e-template
Mar 16, 2026
Merged

martinrrm merged 6 commits into
devfrom
dev-martinrrm-fix-e2e-template

Conversation

@martinrrm

@martinrrm martinrrm commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Bug

Fixes:

Description

1. Fix legacy web project templates so they work under VS 18

Some E2E tests create legacy ASP.NET web application projects through DTE using the templates under:

  • test\EndToEnd\ProjectTemplates\EmptyWebApplicationProject40.zip
  • test\EndToEnd\ProjectTemplates\WebApplicationProject40.zip

The failing tests were surfacing this error:

Operation could not be completed. The project file '...EmptyWebApplicationProject40_070f.csproj' cannot be migrated. See the migration report for details.

That message is misleading. The project was not actually failing because of a real project migration problem.

The real issue was that the legacy templates were hard-coding the VS 17 web targets path:

   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" />

That works when the test runs against VS 17, but it breaks when the E2E harness uses VS 18. Under VS 18, the targets live under v18.0, so the project creation flow fails
while Visual Studio is creating the temp project from the template, and DTE surfaces that inner import failure as a generic "cannot be migrated" error.

This PR updates both templates to resolve the web targets dynamically through $(VisualStudioVersion) / $(VSToolsPath) instead:

   <PropertyGroup>
     <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">17.0</VisualStudioVersion>
     <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
   </PropertyGroup>

   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

This keeps the old template behavior but allows the same asset to resolve correctly when the tests run against newer Visual Studio instances.

2. Fix InstallPackagesConfigLocal by packaging the current test metadata into EndToEnd.zip

`
Test-InstallPackagesConfigLocal expects the local packages.config scenario to install packages A and B:
$pathToPackagesConfig = Join-Path $context.RepositoryRoot "InstallPackagesConfigLocal\packages.config"

$p | Install-Package $pathToPackagesConfig

Assert-Package $p A 1.0.0
Assert-Package $p B 1.0.0
`

The source-controlled test data for that scenario is:

   <?xml version="1.0" encoding="utf-8"?>
   <packages>
     <package id="A" version="1.0.0" targetFramework="net45" userInstalled="true" />
     <package id="B" version="1.0.0" targetFramework="net45" userInstalled="true" />
   </packages>

However, the generated runnable E2E bundle (EndToEnd.zip) was not reliably using the current test\EndToEnd\Packages metadata. Instead, CreateEndToEndTestPackage.proj was
filling the bundled Packages folder from the restored NuGet.Client.EndToEnd.TestData package, which still contained stale scenario metadata.

That meant the runnable test bundle had drifted from source control. The failure:
Value is null. Package A 1.0.0 is not referenced in ClassLibrary_f4c0.

was only the symptom. The real problem was that the assembled E2E environment was not feeding the test the expected packages.config, so A was never installed in the first place.

The packaging logic previously did this:

   <Artifact Include="$([MSBuild]::NormalizeDirectory($(PkgNuGet_Client_EndToEnd_TestData), 'content', 'Packages'))"
             FileMatch="*"
             DestinationFolder="$([MSBuild]::NormalizeDirectory($(WorkingDirectory), 'Packages'))" />

This PR keeps that copy, but then overlays the current source-controlled test\EndToEnd\Packages content on top of it:

   <Artifact Include="$([MSBuild]::NormalizeDirectory($(PkgNuGet_Client_EndToEnd_TestData), 'content', 'Packages'))"
             FileMatch="*"
             DestinationFolder="$([MSBuild]::NormalizeDirectory($(WorkingDirectory), 'Packages'))" />

   <Artifact Include="$([MSBuild]::NormalizeDirectory($(EnlistmentRoot), 'test', 'EndToEnd', 'Packages'))"
             FileMatch="*"
             DestinationFolder="$([MSBuild]::NormalizeDirectory($(WorkingDirectory), 'Packages'))" />

This is intentionally narrow:

  • it preserves the packaged .nupkg payloads that already come from NuGet.Client.EndToEnd.TestData
  • it ensures that current repo metadata such as packages.config, nuspecs, and other scenario files win over stale packaged content

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@martinrrm
martinrrm requested a review from a team as a code owner March 11, 2026 22:21
nkolev92
nkolev92 previously approved these changes Mar 11, 2026

@donnie-msft donnie-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a lot of investigation has taken place. Thanks for writing that up! I have a couple questions around how this all works.

@martinrrm

Copy link
Copy Markdown
Contributor Author

Tests are no longer failing to the Unable to create Project error https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13564562&view=results

@martinrrm martinrrm changed the title Fix E2E tests errors Update E2E WebApplication templates to fix tests errors in project creation Mar 16, 2026
@martinrrm
martinrrm enabled auto-merge (squash) March 16, 2026 21:13
@martinrrm
martinrrm merged commit 460c27e into dev Mar 16, 2026
16 checks passed
@martinrrm
martinrrm deleted the dev-martinrrm-fix-e2e-template branch March 16, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants