-
-
Notifications
You must be signed in to change notification settings - Fork 15
feat: make missing Microsoft.WebApplication.targets configurable #110
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Diagnostics (message IDs) | ||
|
|
||
| Messages emitted by `MSBuild.SDK.SystemWeb` use the `SYSWEB` prefix followed by a number. | ||
| This page is the central registry of those messages. | ||
|
|
||
| | ID | Severity | Meaning | | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we have a 4th column for 'more info' with a deep dive link for some errors - e.g. 000 and 001 could point to a generic WebApplicationsTarget.md file which has all the information about how it is normally derived ( |
||
| |----|----------|---------| | ||
| | `SYSWEB000` | Error | Invalid value for the `MissingWebApplicationsTargetPathAction` property (expected `Ignore`, `Skip`, `Warn` or `Error`). | | ||
| | `SYSWEB001` | Error / Warning / message | `Microsoft.WebApplication.targets` could not be resolved at `$(WebApplicationsTargetPath)`. Configurable via the `MissingWebApplicationsTargetPathAction` property — see below. | | ||
|
|
||
| ## `MissingWebApplicationsTargetPathAction` | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 2 properties - There are sections for Common Properties (used by the main SDK and RazorLibrary) and the specific ones for the main SDK. I'd like to keep the Diagnostics.md file 'clean' and only have a table of the codes. |
||
|
|
||
| `Microsoft.WebApplication.targets` ships with Visual Studio / the Visual Studio Build Tools, not with | ||
| the .NET SDK. When building with the `dotnet` CLI (Core MSBuild), `$(MSBuildExtensionsPath32)` points at | ||
| the .NET SDK rather than a Visual Studio install, so the default `$(WebApplicationsTargetPath)` may not | ||
| exist and the build would otherwise fail with a cryptic `MSB4019`. | ||
|
|
||
| The `MissingWebApplicationsTargetPathAction` property controls what happens when that file cannot be found: | ||
|
|
||
| | Value | Behaviour | | ||
| |-------|-----------| | ||
| | `Ignore` | Do nothing. | | ||
| | `Skip` | Emit a high-importance informational message (`SYSWEB001`). | | ||
| | `Warn` | Emit a warning (`SYSWEB001`). | | ||
| | `Error` | Emit an error and fail the build (`SYSWEB001`). **Default.** | | ||
|
|
||
| > With `Ignore`, `Skip` or `Warn` the build continues **without** importing `Microsoft.WebApplication.targets`. | ||
| > For a real web project, later targets that depend on it may still fail. These options are intended for | ||
| > scenarios where the web targets are genuinely not needed. | ||
|
|
||
| ### How to resolve a missing `Microsoft.WebApplication.targets` | ||
|
|
||
| - Install Visual Studio, or the Visual Studio Build Tools, with the **web development build tools** workload. | ||
| - Build from a **Visual Studio Developer command prompt** (which sets the correct environment). | ||
| - Set `VSToolsPath` (or `WebApplicationsTargetPath`) explicitly, e.g. computed via | ||
| [vswhere](https://github.com/microsoft/vswhere) in a CI pre-build step: | ||
|
|
||
| ```xml | ||
| <!-- e.g. in Directory.Build.props, or pass via -p: on the command line --> | ||
| <PropertyGroup> | ||
| <VSToolsPath>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0</VSToolsPath> | ||
| </PropertyGroup> | ||
| ``` | ||
|
|
||
| To opt out of the failure instead: | ||
|
|
||
| ```xml | ||
| <PropertyGroup> | ||
| <MissingWebApplicationsTargetPathAction>Warn</MissingWebApplicationsTargetPathAction> | ||
| </PropertyGroup> | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,9 @@ At evaluation time, MSBuild adds implicit imports at the top and bottom of the p | |
|
|
||
| # Useful Information | ||
|
|
||
| ## Diagnostics | ||
| - [Message IDs and the `MissingWebApplicationsTargetPathAction` property](Diagnostics.md) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should just reference the Message IDs here. |
||
|
|
||
| ## Binding Redirects | ||
| - [How to show Suggested Binding Redirects](Binding_Redirects/How-to-show-Suggested-Binding-Redirects.md) | ||
| - [Autogenerating Binding Redirects](Binding_Redirects/Autogenerating-Binding-Redirects.md) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> | ||
| <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
| <WebApplicationsTargetPath Condition=" '$(WebApplicationsTargetPath)' == '' ">$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets</WebApplicationsTargetPath> | ||
| <MissingWebApplicationsTargetPathAction Condition="'$(MissingWebApplicationsTargetPathAction)' == ''">Error</MissingWebApplicationsTargetPathAction> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Default item excludes --> | ||
|
|
@@ -25,5 +26,26 @@ | |
| <!-- Inject BindingRedirects targets after Microsoft.NET.Sdk is injected --> | ||
| <Import Project="MSBuild.SDK.SystemWeb.BindingRedirects.targets" /> | ||
|
|
||
| <Import Project="$(WebApplicationsTargetPath)" /> | ||
| <Import Project="$(WebApplicationsTargetPath)" Condition="Exists('$(WebApplicationsTargetPath)')" /> | ||
|
|
||
| <!-- When Microsoft.WebApplication.targets is missing, react per $(MissingWebApplicationsTargetPathAction) | ||
| instead of failing with a cryptic MSB4019. See docs/Diagnostics.md (SYSWEB000/SYSWEB001). --> | ||
| <Target Name="_SystemWebCheckWebApplicationsTargetPath" | ||
| BeforeTargets="BeforeBuild" | ||
| Condition="!Exists('$(WebApplicationsTargetPath)')"> | ||
|
|
||
| <PropertyGroup> | ||
| <_SystemWebMissingWebTargetsText>SYSWEB001: 'Microsoft.WebApplication.targets' was not found at '$(WebApplicationsTargetPath)'. Install Visual Studio or the Visual Studio Build Tools with the "web development build tools" workload, build from a Visual Studio Developer command prompt, or set the 'VSToolsPath' (or 'WebApplicationsTargetPath') property to a valid Visual Studio tools path. Use the 'MissingWebApplicationsTargetPathAction' property (Ignore | Skip | Warn | Error) to control this behaviour.</_SystemWebMissingWebTargetsText> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Reject unknown values up front. --> | ||
| <Error Code="SYSWEB000" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Error and Warn actions should have the HelpLink property pointing to https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/blob/main/docs/Diagnostics.md#SYSWEB000 etc. Hopefully we can put anchors into the markup.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either that or we have a file per error (or group of errors) and directly link to that. |
||
| Condition="'$(MissingWebApplicationsTargetPathAction)' != 'Ignore' and '$(MissingWebApplicationsTargetPathAction)' != 'Skip' and '$(MissingWebApplicationsTargetPathAction)' != 'Warn' and '$(MissingWebApplicationsTargetPathAction)' != 'Error'" | ||
| Text="SYSWEB000: Unknown MissingWebApplicationsTargetPathAction '$(MissingWebApplicationsTargetPathAction)'. Valid values are: Ignore, Skip, Warn, Error." /> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if the default is to have the error code at the start of the text - I thought it would be implicit from the |
||
|
|
||
| <Error Code="SYSWEB001" Text="$(_SystemWebMissingWebTargetsText)" Condition="'$(MissingWebApplicationsTargetPathAction)' == 'Error'" /> | ||
| <Warning Code="SYSWEB001" Text="$(_SystemWebMissingWebTargetsText)" Condition="'$(MissingWebApplicationsTargetPathAction)' == 'Warn'" /> | ||
| <Message Importance="high" Text="$(_SystemWebMissingWebTargetsText)" Condition="'$(MissingWebApplicationsTargetPathAction)' == 'Skip'" /> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the message can't have a helplink or code (yet?), here we could include them directly into the Text="SYSWEB001: $(_SystemWebMissingWebTargetsText) - $(_SystemWebMissingWebTargetsLink)" |
||
| <!-- 'Ignore' => no output --> | ||
| </Target> | ||
| </Project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm coming round to SYSWEB as the prefix - in another issue I had suggested SWSDK for SystemWebSDK.