Skip to content
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

Stub out ResolveComReference task to give proper error message during… #3987

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,31 @@ public ResolveCodeAnalysisRuleSet() { }
public string ResolvedCodeAnalysisRuleSet { get { throw null; } }
public override bool Execute() { throw null; }
}
public sealed partial class ResolveComReference : Microsoft.Build.Tasks.TaskExtension
{
public ResolveComReference() { }
public bool DelaySign { get { throw null; } set { } }
public string[] EnvironmentVariables { get { throw null; } set { } }
public bool ExecuteAsTool { get { throw null; } set { } }
public bool IncludeVersionInInteropName { get { throw null; } set { } }
public string KeyContainer { get { throw null; } set { } }
public string KeyFile { get { throw null; } set { } }
public bool NoClassMembers { get { throw null; } set { } }
public Microsoft.Build.Framework.ITaskItem[] ResolvedAssemblyReferences { get { throw null; } set { } }
[Microsoft.Build.Framework.OutputAttribute]
public Microsoft.Build.Framework.ITaskItem[] ResolvedFiles { get { throw null; } set { } }
[Microsoft.Build.Framework.OutputAttribute]
public Microsoft.Build.Framework.ITaskItem[] ResolvedModules { get { throw null; } set { } }
public string SdkToolsPath { get { throw null; } set { } }
public bool Silent { get { throw null; } set { } }
public string StateFile { get { throw null; } set { } }
public string TargetFrameworkVersion { get { throw null; } set { } }
public string TargetProcessorArchitecture { get { throw null; } set { } }
public Microsoft.Build.Framework.ITaskItem[] TypeLibFiles { get { throw null; } set { } }
public Microsoft.Build.Framework.ITaskItem[] TypeLibNames { get { throw null; } set { } }
public string WrapperOutputDirectory { get { throw null; } set { } }
public override bool Execute() { throw null; }
}
public partial class ResolveKeySource : Microsoft.Build.Tasks.TaskExtension
{
public ResolveKeySource() { }
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/Microsoft.Build.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
<Compile Include="CommandLineBuilderExtension.cs">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>
<Compile Include="ResolveComReference.cs" />
<Compile Include="BuildCacheDisposeWrapper.cs" />
<Compile Include="DownloadFile.cs" />
<Compile Include="FileIO\GetFileHash.cs" />
Expand Down Expand Up @@ -610,7 +611,6 @@
</Compile>
<Compile Include="ResGen.cs" />
<Compile Include="ResGenDependencies.cs" />
<Compile Include="ResolveComReference.cs" />
<Compile Include="ResolveComReferenceCache.cs">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>
Expand Down
206 changes: 154 additions & 52 deletions src/Tasks/ResolveComReference.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if FEATURE_APPDOMAIN

using System;
using System.Collections;
using System.Collections.Generic;
Expand All @@ -23,85 +21,213 @@

namespace Microsoft.Build.Tasks
{
/// <summary>
/// Main class for the COM reference resolution task
/// </summary>
public sealed partial class ResolveComReference : AppDomainIsolatedTaskExtension, IComReferenceResolver
internal interface IResolveComReferenceTaskContract
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
{
#region Properties

/// <summary>
/// COM references specified by guid/version/lcid
/// </summary>
public ITaskItem[] TypeLibNames { get; set; }
ITaskItem[] TypeLibNames { get; set; }

/// <summary>
/// COM references specified by type library file path
/// </summary>
public ITaskItem[] TypeLibFiles { get; set; }
ITaskItem[] TypeLibFiles { get; set; }

/// <summary>
/// Array of equals-separated pairs of environment
/// variables that should be passed to the spawned tlbimp.exe and aximp.exe,
/// in addition to (or selectively overriding) the regular environment block.
/// </summary>
public string[] EnvironmentVariables { get; set; }

/// <summary>
/// merged array containing typeLibNames and typeLibFiles (internal for unit testing)
/// </summary>
internal List<ComReferenceInfo> allProjectRefs;

/// <summary>
/// array containing all dependency references
/// </summary>
internal List<ComReferenceInfo> allDependencyRefs;
string[] EnvironmentVariables { get; set; }

/// <summary>
/// the directory wrapper files get generated into
/// </summary>
public string WrapperOutputDirectory { get; set; }
string WrapperOutputDirectory { get; set; }

/// <summary>
/// When set to true, the typelib version will be included in the wrapper name. Default is false.
/// </summary>
public bool IncludeVersionInInteropName { get; set; }
bool IncludeVersionInInteropName { get; set; }

/// <summary>
/// source of resolved .NET assemblies - we need this for ActiveX wrappers, since we can't resolve .NET assembly
/// references ourselves
/// </summary>
public ITaskItem[] ResolvedAssemblyReferences { get; set; }
ITaskItem[] ResolvedAssemblyReferences { get; set; }

/// <summary>
/// container name for public/private keys
/// </summary>
public string KeyContainer { get; set; }
string KeyContainer { get; set; }

/// <summary>
/// file containing public/private keys
/// </summary>
public string KeyFile { get; set; }
string KeyFile { get; set; }

/// <summary>
/// delay sign wrappers?
/// </summary>
public bool DelaySign { get; set; }
bool DelaySign { get; set; }

/// <summary>
/// Passes the TypeLibImporterFlags.PreventClassMembers flag to tlb wrapper generation
/// </summary>
public bool NoClassMembers { get; set; }
bool NoClassMembers { get; set; }

/// <summary>
/// If true, do not log messages or warnings. Default is false.
/// </summary>
public bool Silent { get; set; }
bool Silent { get; set; }

/// <summary>
/// The preferred target processor architecture. Passed to tlbimp.exe /machine flag after translation.
/// Should be a member of Microsoft.Build.Utilities.ProcessorArchitecture.
/// </summary>
string TargetProcessorArchitecture { get; set; }

/// <summary>
/// Property to allow multitargeting of ResolveComReferences: If true, tlbimp.exe
/// from the appropriate target framework will be run out-of-proc to generate
/// the necessary wrapper assemblies. Aximp is always run out of proc.
/// </summary>
bool ExecuteAsTool { get; set; }

/// <summary>
/// paths to found/generated reference wrappers
/// </summary>
[Output]
ITaskItem[] ResolvedFiles { get; set; }

/// <summary>
/// paths to found modules (needed for isolation)
/// </summary>
[Output]
ITaskItem[] ResolvedModules { get; set; }

/// <summary>
/// If ExecuteAsTool is true, this must be set to the SDK
/// tools path for the framework version being targeted.
/// </summary>
string SdkToolsPath { get; set; }

/// <summary>
/// Cache file for COM component timestamps. If not present, every run will regenerate all the wrappers.
/// </summary>
string StateFile { get; set; }

/// <summary>
/// The project target framework version.
///
/// Default is empty. which means there will be no filtering for the reference based on their target framework.
/// </summary>
string TargetFrameworkVersion { get; set; }

#endregion
}

#if NETSTANDARD || !FEATURE_APPDOMAIN

/// <summary>
/// Main class for the COM reference resolution task for .NET Core
/// </summary>
public sealed partial class ResolveComReference : Microsoft.Build.Tasks.TaskExtension, IResolveComReferenceTaskContract
{
#region Properties

public ITaskItem[] TypeLibNames { get; set; }

public ITaskItem[] TypeLibFiles { get; set; }

public string[] EnvironmentVariables { get; set; }

public string WrapperOutputDirectory { get; set; }

public bool IncludeVersionInInteropName { get; set; }

public ITaskItem[] ResolvedAssemblyReferences { get; set; }

public string KeyContainer { get; set; }

public string KeyFile { get; set; }

public bool DelaySign { get; set; }

public bool NoClassMembers { get; set; }

public bool Silent { get; set; }

public string TargetProcessorArchitecture { get; set; }

public bool ExecuteAsTool { get; set; } = true;

[Output]
public ITaskItem[] ResolvedFiles { get; set; }

[Output]
public ITaskItem[] ResolvedModules { get; set; }

public string SdkToolsPath { get; set; }

public string StateFile { get; set; }

public string TargetFrameworkVersion { get; set; } = String.Empty;

#endregion

#region ITask members

/// <summary>
/// Task entry point.
/// </summary>
/// <returns></returns>
public override bool Execute()
{
Log.LogErrorFromResources("TaskRequiresFrameworkFailure", nameof(ResolveComReference));
return false;
}

#endregion
}

#else

/// <summary>
/// Main class for the COM reference resolution task
/// </summary>
public sealed partial class ResolveComReference : AppDomainIsolatedTaskExtension, IResolveComReferenceTaskContract, IComReferenceResolver
{
#region Properties

public ITaskItem[] TypeLibNames { get; set; }

public ITaskItem[] TypeLibFiles { get; set; }

public string[] EnvironmentVariables { get; set; }

internal List<ComReferenceInfo> allProjectRefs;

internal List<ComReferenceInfo> allDependencyRefs;

public string WrapperOutputDirectory { get; set; }

public bool IncludeVersionInInteropName { get; set; }

public ITaskItem[] ResolvedAssemblyReferences { get; set; }

public string KeyContainer { get; set; }

public string KeyFile { get; set; }

public bool DelaySign { get; set; }

public bool NoClassMembers { get; set; }

public bool Silent { get; set; }

public string TargetProcessorArchitecture
{
get => _targetProcessorArchitecture;
Expand Down Expand Up @@ -137,42 +263,18 @@ public string TargetProcessorArchitecture

private string _targetProcessorArchitecture;

/// <summary>
/// Property to allow multitargeting of ResolveComReferences: If true, tlbimp.exe
/// from the appropriate target framework will be run out-of-proc to generate
/// the necessary wrapper assemblies. Aximp is always run out of proc.
/// </summary>
public bool ExecuteAsTool { get; set; } = true;

/// <summary>
/// paths to found/generated reference wrappers
/// </summary>
[Output]
public ITaskItem[] ResolvedFiles { get; set; }

/// <summary>
/// paths to found modules (needed for isolation)
/// </summary>
[Output]
public ITaskItem[] ResolvedModules { get; set; }

/// <summary>
/// If ExecuteAsTool is true, this must be set to the SDK
/// tools path for the framework version being targeted.
/// </summary>
public string SdkToolsPath { get; set; }

/// <summary>
/// Cache file for COM component timestamps. If not present, every run will regenerate all the wrappers.
/// </summary>
public string StateFile { get; set; }

/// <summary>
/// The project target framework version.
///
/// Default is empty. which means there will be no filtering for the reference based on their target framework.
/// </summary>
/// <value></value>
public string TargetFrameworkVersion { get; set; } = String.Empty;

private Version _projectTargetFramework;
Expand Down Expand Up @@ -1655,6 +1757,6 @@ internal static TYPELIBATTR TaskItemToTypeLibAttr(ITaskItem taskItem)

#endregion
}
}

#endif
}
6 changes: 6 additions & 0 deletions src/Tasks/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2673,6 +2673,12 @@
<comment>{StrBegin="MSB4801: "}</comment>
</data>

<!-- Some tasks are only supported on .NET Framework -->
<data name="TaskRequiresFrameworkFailure" xml:space="preserve">
<value>MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</value>
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
<comment>{StrBegin="MSB4803: "}</comment>
</data>

<!--
MSB3921 - MSB3930 Task: DownloadFile
-->
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,11 @@
<target state="translated">MSB3353: Nebyl zadán veřejný klíč nezbytný ke zpožděnému podepsání.</target>
<note>{StrBegin="MSB3353: "}</note>
</trans-unit>
<trans-unit id="TaskRequiresFrameworkFailure">
<source>MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</source>
<target state="new">MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</target>
<note>{StrBegin="MSB4803: "}</note>
</trans-unit>
<trans-unit id="TlbImp.InvalidTransformParameter">
<source>MSB3661: Invalid value '{0}' passed to the Transform property.</source>
<target state="translated">MSB3661: Vlastnosti Transform byla předána neplatná hodnota {0}.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,11 @@
<target state="translated">MSB3353: Der für die verzögerte Signierung erforderliche öffentliche Schlüssel wurde nicht angegeben.</target>
<note>{StrBegin="MSB3353: "}</note>
</trans-unit>
<trans-unit id="TaskRequiresFrameworkFailure">
<source>MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</source>
<target state="new">MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</target>
<note>{StrBegin="MSB4803: "}</note>
</trans-unit>
<trans-unit id="TlbImp.InvalidTransformParameter">
<source>MSB3661: Invalid value '{0}' passed to the Transform property.</source>
<target state="translated">MSB3661: Der ungültige Wert "{0}" wurde an die Transform-Eigenschaft übergeben.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Resources/xlf/Strings.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,11 @@
<target state="new">MSB3353: Public key necessary for delay signing was not specified.</target>
<note>{StrBegin="MSB3353: "}</note>
</trans-unit>
<trans-unit id="TaskRequiresFrameworkFailure">
<source>MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</source>
<target state="new">MSB4803: The task "{0}" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/MSBuildProduct for further details.</target>
<note>{StrBegin="MSB4803: "}</note>
</trans-unit>
<trans-unit id="TlbImp.InvalidTransformParameter">
<source>MSB3661: Invalid value '{0}' passed to the Transform property.</source>
<target state="new">MSB3661: Invalid value '{0}' passed to the Transform property.</target>
Expand Down
Loading