|
1 |
| -// |
2 |
| -// Copyright (c) .NET Foundation and Contributors |
3 |
| -// See LICENSE file in the project root for full license information. |
4 |
| -// |
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
5 | 3 |
|
6 |
| -using Microsoft.VisualStudio.ProjectSystem; |
7 |
| -using Microsoft.VisualStudio.ProjectSystem.References; |
8 | 4 | using System;
|
9 | 5 | using System.Collections.Generic;
|
10 | 6 | using System.Linq;
|
11 | 7 | using System.Reflection;
|
12 | 8 | using System.Threading.Tasks;
|
| 9 | +using Microsoft.VisualStudio.ProjectSystem; |
| 10 | +using Microsoft.VisualStudio.ProjectSystem.References; |
13 | 11 |
|
14 | 12 | namespace nanoFramework.Tools.VisualStudio.Extension
|
15 | 13 | {
|
@@ -90,9 +88,12 @@ public static async Task CollectAssembliesToDeployAsync(
|
90 | 88 | foreach (IAssemblyReference assemblyReference in
|
91 | 89 | await project.Services.AssemblyReferences.GetResolvedReferencesAsync())
|
92 | 90 | {
|
93 |
| - // As assemblyPathsToDeploy is a HashSet, the same path will not occure more than once even if added |
94 |
| - // more than once by distinct projects referencing the same NuGet package for example. |
95 |
| - assemblyPathsToDeploy.Add(await assemblyReference.GetFullPathAsync()); |
| 91 | + if (await ShouldDeployToNanoDeviceAsync(assemblyReference)) |
| 92 | + { |
| 93 | + // As assemblyPathsToDeploy is a HashSet, the same path will not occure more than once even if added |
| 94 | + // more than once by distinct projects referencing the same NuGet package for example. |
| 95 | + assemblyPathsToDeploy.Add(await assemblyReference.GetFullPathAsync()); |
| 96 | + } |
96 | 97 | }
|
97 | 98 |
|
98 | 99 | // Recursively process referenced projects in the solution:
|
@@ -125,6 +126,17 @@ await CollectAssembliesToDeployAsync(
|
125 | 126 | }
|
126 | 127 | }
|
127 | 128 |
|
| 129 | + /// <summary> |
| 130 | + /// Find out if a referenced assembly should be included in the deployment or not. |
| 131 | + /// If the Reference element in the (imported) project file has the property "DeployToNanoDevice" set to false, |
| 132 | + /// it will not be included. If the property is not present or set to true, it will be included. |
| 133 | + /// </summary> |
| 134 | + private static async Task<bool> ShouldDeployToNanoDeviceAsync(IAssemblyReference assembly) |
| 135 | + { |
| 136 | + string value = await assembly.Metadata.GetEvaluatedPropertyValueAsync("DeployToNanoDevice"); |
| 137 | + return string.IsNullOrEmpty(value) || !value.Equals("false", StringComparison.OrdinalIgnoreCase); |
| 138 | + } |
| 139 | + |
128 | 140 | /// <summary>
|
129 | 141 | /// Gets the full path to the compiled output of a <see cref="ConfiguredProject"/>.
|
130 | 142 | /// </summary>
|
|
0 commit comments