dotnet / dotnet/msbuild

Setting `TargetFrameworkMoniker` takes no effect in AspNetCompiler task

Open
#2,745 1 comment 2 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

### Steps to reproduce

Project file, I named it "PrecompileWebForm.proj"
```xml


PhysicalPathToMyWebFormFolder
E:\Downloads\PublishedSite
DemoSite




```

Directory contents:

A standard ASP.NET 3.5 WebForm project directory.

Command line
```
msbuild PrecompileWebForm.proj
```
### Expected behavior

The `AspNetCompiler` task should use `C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe` since I set `TargetFrameworkMoniker="net35"`.

### Actual behavior

The `AspNetCompiler` task ignores the `TargetFrameworkMoniker` setting and uses `C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe`

### Environment data
`msbuild /version` output:

Microsoft (R) Build Engine version 15.4.8.50001 for .NET Framework

OS info:

Windows 10 1709 (OS Build 16299.64)

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):

I invokes msbuild in PowerShell manually.

### Notes

I read the source code and figured out that the `TargetFrameworkMoniker` is not used in `GenerateFullPathToTool` method. 😓

https://github.com/Microsoft/msbuild/blob/master/src/Tasks/AspNetCompiler.cs#L331

### Workaround

Set `ToolExe` attribute directly in `AspNetCompiler` task

```xml

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/Tasks/AspNetCompiler.cs around GenerateFullPathToTool, where the issue notes that TargetFrameworkMoniker is not used. Reproduce with the provided PrecompileWebForm.proj and msbuild command, then verify that net35 selects the expected ASP.NET compiler path instead of the .NET Framework 4 executable.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.