diff --git a/Releasing_MSBuildLocator.md b/Releasing_MSBuildLocator.md
index 4270b46..0c83875 100644
--- a/Releasing_MSBuildLocator.md
+++ b/Releasing_MSBuildLocator.md
@@ -5,10 +5,10 @@ These instructions can only be followed by Microsoft-internal MSBuild maintainer
1. Create a PR in https://github.com/microsoft/MSBuildLocator
2. Have it reviewed.
3. Once approved, merge it.
-4. It will automatically start a pipeline build [here](https://dev.azure.com/devdiv/DevDiv/_build?definitionId=11881).
-5. Once it succeeds, proceed to [our release page](https://dev.azure.com/devdiv/DevDiv/_release?_a=releases&view=mine&definitionId=408) and create a release (top-right). Specify the build that succeeded.
-6. At some point, it will stop to request permission to continue. If you want to publish to NuGet, do so, clicking Approve. It will make a little more progress and push to NuGet! It will then give you the option to "resume" (or cancel) twice. Do so.
-
+4. Start a pipeline build [here](https://dev.azure.com/devdiv/DevDiv/_build?definitionId=11881) for the commited changes.
+5. Once it succeeds, proceed to [our release pipeline](https://dev.azure.com/devdiv/DevDiv/_build?definitionId=27492) and queue release. Specify the build that succeeded.
+6. On Public NuGet release stage it will stop to request permission to continue. If you want to publish to NuGet, do so, clicking Approve.
+
### Releasing a non-preview version of MSBuildLocator
The above steps will push a package to NuGet.org, but it is a preview version. To make a final release branded version, merge the latest changes into a release branch like `release/1.5`. Follow the steps as above, and it will publish a release package to NuGet.org.
diff --git a/docs/diagnostics/MSBL001.md b/docs/diagnostics/MSBL001.md
index 2c2ab5b..5b7f677 100644
--- a/docs/diagnostics/MSBL001.md
+++ b/docs/diagnostics/MSBL001.md
@@ -2,11 +2,11 @@
## Error Message
-> A PackageReference to the package '{PackageId}' at version '{Version}' is present in this project without ExcludeAssets="runtime" set. This can cause errors at run-time due to MSBuild assembly-loading.
+> A PackageReference to the package '{PackageId}' at version '{Version}' is present in this project without ExcludeAssets="runtime" and PrivateAssets="all" set. This can cause errors at run-time due to MSBuild assembly-loading.
## Cause
-This error occurs when your project references MSBuild NuGet packages (such as `Microsoft.Build`, `Microsoft.Build.Framework`, `Microsoft.Build.Utilities.Core`, etc.) without excluding their runtime assets. When you use Microsoft.Build.Locator, you want MSBuildLocator to load MSBuild assemblies from an installed Visual Studio or .NET SDK instance, not from the NuGet packages in your output directory.
+This error occurs when your project references MSBuild NuGet packages (such as `Microsoft.Build`, `Microsoft.Build.Framework`, `Microsoft.Build.Utilities.Core`, etc.) without excluding their runtime assets and marking them as private. When you use Microsoft.Build.Locator, you want MSBuildLocator to load MSBuild assemblies from an installed Visual Studio or .NET SDK instance, not from the NuGet packages in your output directory.
## Why This Is a Problem
@@ -16,9 +16,11 @@ When MSBuild runtime assemblies are copied to your application's output director
2. **Missing SDKs and build logic**: The MSBuild assemblies in your output directory don't include the SDKs, targets, and build logic needed to build real projects
3. **Inconsistent behavior**: Your application may behave differently than `MSBuild.exe`, `dotnet build`, or Visual Studio when evaluating projects
+Additionally, without `PrivateAssets="all"`, downstream projects that reference your project may still get these runtime assets transitively, causing the same issues in consuming projects.
+
## Example Runtime Error
-Without `ExcludeAssets="runtime"`, you may encounter errors like:
+Without the proper asset exclusions, you may encounter errors like:
```
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
@@ -34,18 +36,27 @@ This happens because your application loads MSBuild assemblies from your bin fol
## Solution
-Add `ExcludeAssets="runtime"` to all MSBuild PackageReferences in your project file:
+Add `ExcludeAssets="runtime"` and `PrivateAssets="all"` to all MSBuild PackageReferences in your project file:
```xml
-
-
-
+
+
+
...
```
-This tells NuGet to use these packages only for compilation, not at runtime. At runtime, MSBuildLocator will load MSBuild assemblies from the registered Visual Studio or .NET SDK installation.
+- `ExcludeAssets="runtime"` tells NuGet to use these packages only for compilation, not at runtime. At runtime, MSBuildLocator will load MSBuild assemblies from the registered Visual Studio or .NET SDK installation.
+- `PrivateAssets="all"` prevents the package reference metadata from flowing to downstream projects, ensuring that projects referencing your library don't inadvertently get runtime assets from these packages.
+
+> [!NOTE]
+> Make sure that you don't add `ExcludeAssets` and `PrivateAssets` to the `Microsoft.Build.Locator` `PackageReference` itself - you need its run-time assets in order to use it!
+
+### What if I get errors for PackageReferences I don't have?
+
+It's possible that you may get `MSBL001` errors for packages that you don't directly reference - these packages are _transitive_ references, pulled in by other packages you _do_ reference.
+To solve this, you'll need to add new PackageReference items to your project and add the ExcludeAssets/PrivateAssets metadata onto them. In the future we hope to have the ability to 'flow' this metadata from a parent PackageReference to transitive PackageReferences so that you don't need to do this.
## Alternative: Disable the Check (Not Recommended)
diff --git a/release-pipeline.yml b/release-pipeline.yml
index 33a7478..260bf6f 100644
--- a/release-pipeline.yml
+++ b/release-pipeline.yml
@@ -6,6 +6,11 @@ resources:
source: microsoft.MSBuildLocator
trigger:
enabled: false
+ repositories:
+ - repository: 1ESPipelineTemplates
+ type: git
+ name: 1ESPipelineTemplates/1ESPipelineTemplates
+ ref: refs/tags/release
variables:
SymbolsFeatureName: 'MSBuild'
@@ -13,80 +18,58 @@ variables:
TeamName: 'msbuild'
VstsDropNames: 'Products/DevDiv/Microsoft/msbuild/$(Build.SourceBranchName)/$(Build.BuildNumber)/$(Build.BuildId)'
-stages:
-- stage: RetainBuild
- displayName: 'Retain build'
- jobs:
- - job: RetainBuildJob
- displayName: 'Run on agent'
+extends:
+ template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
+ parameters:
+ settings:
+ networkIsolationPolicy: Permissive,CFSClean
pool:
- name: 'VSEngSS-MicroBuild2022-1ES'
- steps:
- - download: microsoft_MSBuildLocator
- displayName: 'Download Symbols Artifact'
- artifact: Symbols
+ name: VSEngSS-MicroBuild2022-1ES
+ stages:
+ - stage: RetainBuild
+ displayName: 'Retain build'
+ jobs:
+ - job: RetainBuildJob
+ displayName: 'Run on agent'
+ steps:
+ - download: microsoft_MSBuildLocator
+ displayName: 'Download Symbols Artifact'
+ artifact: Symbols
- - task: MicroBuildArchiveSymbols@6
- displayName: 'Archive $(SymbolsFeatureName) on Symweb'
- inputs:
- SymbolsFeatureName: '$(SymbolsFeatureName)'
- SymbolsProject: '$(SymbolsProject)'
- SymbolsAgentPath: '$(Pipeline.Workspace)/microsoft_MSBuildLocator/Symbols'
- SubmitToInternet: true
- ExpirationInDays: '5475'
- azureSubscription: 'VSEng-SymbolsUpload'
- env:
- SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+ - task: MicroBuildArchiveSymbols@6
+ displayName: 'Archive $(SymbolsFeatureName) on Symweb'
+ inputs:
+ SymbolsFeatureName: '$(SymbolsFeatureName)'
+ SymbolsProject: '$(SymbolsProject)'
+ SymbolsAgentPath: '$(Pipeline.Workspace)/microsoft_MSBuildLocator/Symbols'
+ SubmitToInternet: true
+ ExpirationInDays: '5475'
+ azureSubscription: 'VSEng-SymbolsUpload'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- - task: MicroBuildRetainVstsDrops@1
- displayName: 'Retain VSTS Drops'
- enabled: false
- inputs:
- DropNames: '$(VstsDropNames)'
- DropServiceUri: 'https://devdiv.artifacts.visualstudio.com/DefaultCollection'
-
-- stage: PublicRelease
- displayName: 'Public release'
- dependsOn: RetainBuild
- condition: succeeded()
- jobs:
- - job: PushToNuGet
- displayName: 'Push to nuget.org'
- pool:
- name: 'VSEngSS-MicroBuild2022-1ES'
- steps:
- - download: microsoft_MSBuildLocator
- displayName: 'Download NuGet Package Artifact'
- artifact: pkg
- - task: NuGetCommand@2
- displayName: 'NuGet push'
- inputs:
- command: 'push'
- packagesToPush: '$(Pipeline.Workspace)/microsoft_MSBuildLocator/pkg/Microsoft.Build.Locator*.nupkg'
- nuGetFeedType: 'external'
- publishFeedCredentials: 'MSBuild-Locator'
- verbosityPush: 'Detailed'
-
- - job: PublicNuGetRelease
- displayName: 'Public NuGet release'
- dependsOn: PushToNuGet
- pool: server
- steps:
- - task: ManualValidation@0
- displayName: 'Push packages to NuGet'
- inputs:
- instructions: |
- https://microsoft.sharepoint.com/teams/toolsforeng/_layouts/OneNote.aspx?id=%2Fteams%2Ftoolsforeng%2FOne%20Note%2FToolsForSoftwareEngineers&wd=target%28Build%20Tools%2FMSBuild%2FGitHub.one%7CFF6DC598-65EC-43D5-AB29-DB38FEB82BC8%2FMyGet%20Feed%7CFAFC6258-899D-48D4-8DB4-892396202C9C%2F%29
- onenote:https://microsoft.sharepoint.com/teams/toolsforeng/One%20Note/ToolsForSoftwareEngineers/Build%20Tools/MSBuild/GitHub.one#MyGet%20Feed§ion-id={FF6DC598-65EC-43D5-AB29-DB38FEB82BC8}&page-id={FAFC6258-89
- onTimeout: 'reject'
+ - task: MicroBuildRetainVstsDrops@1
+ displayName: 'Retain VSTS Drops'
+ enabled: false
+ inputs:
+ DropNames: '$(VstsDropNames)'
+ DropServiceUri: 'https://devdiv.artifacts.visualstudio.com/DefaultCollection'
- - job: GitHubRelease
- displayName: 'GitHub release'
- dependsOn: PublicNuGetRelease
- pool: server
- steps:
- - task: ManualValidation@0
- displayName: 'Create GitHub release'
- inputs:
- instructions: 'Create the GitHub release manually'
- onTimeout: 'reject'
+ - stage: PublicRelease
+ displayName: 'Public release'
+ dependsOn: RetainBuild
+ condition: succeeded()
+ jobs:
+ - job: PushToNuGet
+ displayName: 'Push to nuget.org'
+ steps:
+ - download: microsoft_MSBuildLocator
+ displayName: 'Download NuGet Package Artifact'
+ artifact: pkg
+ - task: 1ES.PublishNuget@1
+ displayName: 'NuGet push'
+ inputs:
+ packageParentPath: '$(Pipeline.Workspace)'
+ packagesToPush: '$(Pipeline.Workspace)/microsoft_MSBuildLocator/pkg/Microsoft.Build.Locator*.nupkg'
+ nuGetFeedType: 'external'
+ publishFeedCredentials: 'MSBuild-Locator'
diff --git a/src/MSBuildLocator/build/Microsoft.Build.Locator.targets b/src/MSBuildLocator/build/Microsoft.Build.Locator.targets
index 6cbe80d..f110be0 100644
--- a/src/MSBuildLocator/build/Microsoft.Build.Locator.targets
+++ b/src/MSBuildLocator/build/Microsoft.Build.Locator.targets
@@ -19,7 +19,7 @@