Skip to content

Conversation

@dsplaisted
Copy link
Member

This spec covers some of the implementation for optional SDK workloads in .NET 5. The overall spec is in #100.

dsplaisted and others added 2 commits April 7, 2020 08:49
Co-Authored-By: Alexander Köplinger <[email protected]>
Co-Authored-By: Alexander Köplinger <[email protected]>

MSBuild uses multiple phases for evaluation, and properties and imports are evaluated in a phase before items. This means it is possible to have conditions on item or `ItemGroup` elements in a .props file that depend on properties that are defined in the body of the project or in .targets files.

So workloads may include MSBuild items in the `AutoImport.props` file if they are appropriately conditioned to only activate when the workload is in use. They should not set MSBuild properties, as there is no way to set those properties only if the workload is in use. If workload wants to set a default value for a property, then it should do so in its .targets file with a condition to set the property if it is not already set.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
So workloads may include MSBuild items in the `AutoImport.props` file if they are appropriately conditioned to only activate when the workload is in use. They should not set MSBuild properties, as there is no way to set those properties only if the workload is in use. If workload wants to set a default value for a property, then it should do so in its .targets file with a condition to set the property if it is not already set.
Workloads may include MSBuild items in the `AutoImport.props` file if they are appropriately conditioned to only activate when the workload is in use. They should not set MSBuild properties, as there is no way to set those properties only if the workload is in use. If workload wants to set a default value for a property, then it should do so in its .targets file with a condition to set the property if it is not already set.


So workloads may include MSBuild items in the `AutoImport.props` file if they are appropriately conditioned to only activate when the workload is in use. They should not set MSBuild properties, as there is no way to set those properties only if the workload is in use. If workload wants to set a default value for a property, then it should do so in its .targets file with a condition to set the property if it is not already set.

Note that in contrast to the `WorkloadManifest.targets` file, which is part of the workload manifest package, the `AutoImport.props` files are part of the workload packs (under the Sdk folder). This is so that they can be imported only if the workload is installed, rather than imported for all workloads whether they are installed or not. This reduces the impact of a bug in an `AutoImport.props` file, and means that if there is an issue in the .props file, it can be worked around by uninstalling the workload.
Copy link
Member

Choose a reason for hiding this comment

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

This paragraph and the one before it seems like they duplicate some of the same content and could be streamlined a bit.


## NuGet SDK Resolver

MSBuild includes a [NuGet-based MSBuild SDK resolver](https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2019#how-project-sdks-are-resolved). It will be used if a version number is specified for the SDK, either in the SDK attribute or in a global.json file.
Copy link
Member

Choose a reason for hiding this comment

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

It will be used if a version number is specified for the SDK, either in the SDK attribute or in a global.json file.

I don't quite get this (I'm probably just missing context). I was expecting this to say "If you had an sdk reference other than MS.Net.Sdk".

Copy link
Member Author

Choose a reason for hiding this comment

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

You have to specify a version number in order for the NuGet SDK resolver to kick in. You can specify that either directly in the Sdk attribute: <Project Sdk="MSBuild.Sdk.Extras/2.0.54">, or in global.json:

{
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.0.54"
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

I see. That seems like overly precise wording.

Suggested change
MSBuild includes a [NuGet-based MSBuild SDK resolver](https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2019#how-project-sdks-are-resolved). It will be used if a version number is specified for the SDK, either in the SDK attribute or in a global.json file.
MSBuild includes a [NuGet-based MSBuild SDK resolver](https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2019#how-project-sdks-are-resolved). It will be used if a custom SDK is specified, as an SDK name and version number, either in the SDK attribute in the project file or in a global.json file.

@dsplaisted dsplaisted merged commit 3048e4c into master Apr 14, 2020
@jkotas jkotas deleted the workload-resolvers branch April 29, 2020 15:56
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.

6 participants