diff --git a/src/Tasks/Al.cs b/src/Tasks/Al.cs index 7d9ad8fa1a8..0b587df5b74 100644 --- a/src/Tasks/Al.cs +++ b/src/Tasks/Al.cs @@ -1,21 +1,26 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#if NETFRAMEWORK using System; -using Microsoft.Build.Framework; using Microsoft.Build.Shared.FileSystem; using Microsoft.Build.Utilities; +#endif + +using Microsoft.Build.Framework; #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK + /// /// This class defines the "AL" XMake task, which enables using al.exe to link /// modules and resource files into assemblies. /// - public class AL : ToolTaskExtension + public class AL : ToolTaskExtension, IALTaskContract { #region Properties /* @@ -387,6 +392,130 @@ public override bool Execute() return base.Execute(); } + #endregion + } + +#else + + /// + /// Stub AL task for .NET Core. + /// + public sealed class AL : TaskRequiresFramework, IALTaskContract + { + public AL() + : base(nameof(AL)) + { + } + + #region Properties + + public string AlgorithmId { get; set; } + + public string BaseAddress { get; set; } + + public string CompanyName { get; set; } + + public string Configuration { get; set; } + + public string Copyright { get; set; } + + public string Culture { get; set; } + + public bool DelaySign { get; set; } + + public string Description { get; set; } + + public string EvidenceFile { get; set; } + + public string FileVersion { get; set; } + + public string Flags { get; set; } + + public bool GenerateFullPaths { get; set; } + + public string KeyFile { get; set; } + + public string KeyContainer { get; set; } + + public string MainEntryPoint { get; set; } + + [Output] + public ITaskItem OutputAssembly { get; set; } + + public string Platform { get; set; } + + public bool Prefer32Bit { get; set; } + + public string ProductName { get; set; } + + public string ProductVersion { get; set; } + + public string[] ResponseFiles { get; set; } + + public string TargetType { get; set; } + + public string TemplateFile { get; set; } + + public string Title { get; set; } + + public string Trademark { get; set; } + + public string Version { get; set; } + + public string Win32Icon { get; set; } + + public string Win32Resource { get; set; } + + public ITaskItem[] SourceModules { get; set; } + + public ITaskItem[] EmbedResources { get; set; } + + public ITaskItem[] LinkResources { get; set; } + + public string SdkToolsPath { get; set; } + + #endregion + } + +#endif + + internal interface IALTaskContract + { + #region Properties + + string AlgorithmId { get; set; } + string BaseAddress { get; set; } + string CompanyName { get; set; } + string Configuration { get; set; } + string Copyright { get; set; } + string Culture { get; set; } + bool DelaySign { get; set; } + string Description { get; set; } + string EvidenceFile { get; set; } + string FileVersion { get; set; } + string Flags { get; set; } + bool GenerateFullPaths { get; set; } + string KeyFile { get; set; } + string KeyContainer { get; set; } + string MainEntryPoint { get; set; } + ITaskItem OutputAssembly { get; set; } + string Platform { get; set; } + bool Prefer32Bit { get; set; } + string ProductName { get; set; } + string ProductVersion { get; set; } + string[] ResponseFiles { get; set; } + string TargetType { get; set; } + string TemplateFile { get; set; } + string Title { get; set; } + string Trademark { get; set; } + string Version { get; set; } + string Win32Icon { get; set; } + string Win32Resource { get; set; } + ITaskItem[] SourceModules { get; set; } + ITaskItem[] EmbedResources { get; set; } + ITaskItem[] LinkResources { get; set; } + string SdkToolsPath { get; set; } + #endregion } } diff --git a/src/Tasks/AspNetCompiler.cs b/src/Tasks/AspNetCompiler.cs index 1e1d3b4b2be..3570cc44010 100644 --- a/src/Tasks/AspNetCompiler.cs +++ b/src/Tasks/AspNetCompiler.cs @@ -1,16 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#if NETFRAMEWORK using Microsoft.Build.Utilities; +#endif #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK + /// /// The AspNetCompiler task, which is a wrapper around aspnet_compiler.exe /// - public class AspNetCompiler : ToolTaskExtension + public class AspNetCompiler : ToolTaskExtension, IAspNetCompilerTaskContract { /* C:\WINDOWS\Microsoft.NET\Framework\v2.0.x86dbg>aspnet_compiler /? @@ -338,4 +342,70 @@ protected override bool ValidateParameters() return true; } } + +#else + + public sealed class AspNetCompiler : TaskRequiresFramework, IAspNetCompilerTaskContract + { + public AspNetCompiler() + : base(nameof(AspNetCompiler)) + { + } + + #region Properties + + public bool AllowPartiallyTrustedCallers { get; set; } + + public bool DelaySign { get; set; } + + public bool FixedNames { get; set; } + + public string KeyContainer { get; set; } + + public string KeyFile { get; set; } + + public string MetabasePath { get; set; } + + public string PhysicalPath { get; set; } + + public string TargetPath { get; set; } + + public string VirtualPath { get; set; } + + public bool Updateable { get; set; } + + public bool Force { get; set; } + + public bool Debug { get; set; } + + public bool Clean { get; set; } + + public string TargetFrameworkMoniker { get; set; } + + #endregion + } + +#endif + + internal interface IAspNetCompilerTaskContract + { + #region Properties + + bool AllowPartiallyTrustedCallers { get; set; } + bool DelaySign { get; set; } + bool FixedNames { get; set; } + string KeyContainer { get; set; } + string KeyFile { get; set; } + string MetabasePath { get; set; } + string PhysicalPath { get; set; } + string TargetPath { get; set; } + string VirtualPath { get; set; } + bool Updateable { get; set; } + bool Force { get; set; } + bool Debug { get; set; } + bool Clean { get; set; } + string TargetFrameworkMoniker { get; set; } + + #endregion + } } diff --git a/src/Tasks/CompatibilitySuppressions.xml b/src/Tasks/CompatibilitySuppressions.xml index f89f776d767..9647c21c161 100644 --- a/src/Tasks/CompatibilitySuppressions.xml +++ b/src/Tasks/CompatibilitySuppressions.xml @@ -1,16 +1,76 @@  - - + + CP0007 + T:Microsoft.Build.Tasks.AL + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.AspNetCompiler + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.GenerateBootstrapper + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.GenerateTrustInfo + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.GetFrameworkSdkPath + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.RegisterAssembly + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + CP0007 T:Microsoft.Build.Tasks.ResolveComReference ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll ref/net472/Microsoft.Build.Tasks.Core.dll + + CP0007 + T:Microsoft.Build.Tasks.ResolveNativeReference + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.UnregisterAssembly + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.UpdateManifest + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP0007 + T:Microsoft.Build.Tasks.WinMDExp + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + ref/net472/Microsoft.Build.Tasks.Core.dll + true - + true - + + true + + + true + + + true + + + true + + + + true + + + true + + + true + + + + + true @@ -598,15 +624,6 @@ true - - true - - - true - - - true - true @@ -617,16 +634,10 @@ true - - true - true - - true - true @@ -637,13 +648,6 @@ true - - true - - - true - - @@ -974,11 +978,9 @@ - + - + diff --git a/src/Tasks/Microsoft.Common.tasks b/src/Tasks/Microsoft.Common.tasks index beab1878e60..f8e09491af3 100644 --- a/src/Tasks/Microsoft.Common.tasks +++ b/src/Tasks/Microsoft.Common.tasks @@ -63,7 +63,7 @@ - + @@ -84,7 +84,7 @@ - + diff --git a/src/Tasks/RegisterAssembly.cs b/src/Tasks/RegisterAssembly.cs index 0fb8e616bb3..542e2a8f08b 100644 --- a/src/Tasks/RegisterAssembly.cs +++ b/src/Tasks/RegisterAssembly.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if FEATURE_APPDOMAIN +#if NETFRAMEWORK && FEATURE_APPDOMAIN using System; using System.Diagnostics; @@ -11,20 +11,25 @@ using System.Runtime.InteropServices.ComTypes; using System.Security; -using Microsoft.Build.Framework; using Microsoft.Build.Shared; using Microsoft.Build.Shared.FileSystem; using Microsoft.Build.Utilities; +#endif + +using Microsoft.Build.Framework; + #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK && FEATURE_APPDOMAIN + /// /// Registers a managed assembly for COM interop (equivalent of regasm.exe functionality, but this code doesn't actually call the exe). /// /// ITypeLibExporterNotifySink is necessary for the ITypeLibConverter.ConvertAssemblyToTypeLib call. - public class RegisterAssembly : AppDomainIsolatedTaskExtension, ITypeLibExporterNotifySink + public class RegisterAssembly : AppDomainIsolatedTaskExtension, ITypeLibExporterNotifySink, IRegisterAssemblyTaskContract { #region Properties @@ -360,5 +365,41 @@ private bool ExportTypeLib(Assembly asm, string typeLibFileName) #endregion } -} + +#elif !NETFRAMEWORK + + public sealed class RegisterAssembly : TaskRequiresFramework, IRegisterAssemblyTaskContract + { + public RegisterAssembly() + : base(nameof(RegisterAssembly)) + { + } + + #region Properties + + public ITaskItem[] Assemblies { get; set; } + + [Output] + public ITaskItem[] TypeLibFiles { get; set; } + + public bool CreateCodeBase { get; set; } + + public ITaskItem AssemblyListFile { get; set; } + + #endregion + } + #endif + + internal interface IRegisterAssemblyTaskContract + { + #region Properties + + ITaskItem[] Assemblies { get; set; } + ITaskItem[] TypeLibFiles { get; set; } + bool CreateCodeBase { get; set; } + ITaskItem AssemblyListFile { get; set; } + + #endregion + } +} diff --git a/src/Tasks/ResolveComReference.cs b/src/Tasks/ResolveComReference.cs index 0a3eb949eef..a9fcee543f6 100644 --- a/src/Tasks/ResolveComReference.cs +++ b/src/Tasks/ResolveComReference.cs @@ -139,8 +139,13 @@ internal interface IResolveComReferenceTaskContract /// /// Main class for the COM reference resolution task for .NET Core /// - public sealed partial class ResolveComReference : Microsoft.Build.Tasks.TaskExtension, IResolveComReferenceTaskContract + public sealed partial class ResolveComReference : TaskRequiresFramework, IResolveComReferenceTaskContract { + public ResolveComReference() + : base(nameof(ResolveComReference)) + { + } + #pragma warning disable format // region formatting is different in net7.0 and net472, and cannot be fixed for both #region Properties @@ -183,20 +188,6 @@ public sealed partial class ResolveComReference : Microsoft.Build.Tasks.TaskExte public string TargetFrameworkVersion { get; set; } = String.Empty; #endregion - - #region ITask members - - /// - /// Task entry point. - /// - /// - public override bool Execute() - { - Log.LogErrorWithCodeFromResources("TaskRequiresFrameworkFailure", nameof(ResolveComReference)); - return false; - } - - #endregion #pragma warning restore format } diff --git a/src/Tasks/ResolveNativeReference.cs b/src/Tasks/ResolveNativeReference.cs index 66a5ac3c70b..484401442be 100644 --- a/src/Tasks/ResolveNativeReference.cs +++ b/src/Tasks/ResolveNativeReference.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#if NETFRAMEWORK using System; using System.IO; using System.Collections; @@ -9,20 +10,25 @@ using System.Diagnostics; #endif using System.Linq; -using Microsoft.Build.Framework; + using Microsoft.Build.Shared; using Microsoft.Build.Shared.FileSystem; using Microsoft.Build.Tasks.Deployment.ManifestUtilities; using Microsoft.Build.Utilities; +#endif + +using Microsoft.Build.Framework; #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK + /// /// Main class for the native reference resolution task. /// - public class ResolveNativeReference : TaskExtension + public class ResolveNativeReference : TaskExtension, IResolveNativeReferenceTaskConract { #region Constructors @@ -340,4 +346,58 @@ internal bool ExtractFromManifest( } #endregion } + +#else + + public sealed class ResolveNativeReference : TaskRequiresFramework, IResolveNativeReferenceTaskConract + { + public ResolveNativeReference() + : base(nameof(ResolveNativeReference)) + { + } + + #region Properties + + public ITaskItem[] NativeReferences { get; set; } + + public string[] AdditionalSearchPaths { get; set; } + + [Output] + public ITaskItem[] ContainingReferenceFiles { get; set; } + + [Output] + public ITaskItem[] ContainedPrerequisiteAssemblies { get; set; } + + [Output] + public ITaskItem[] ContainedComComponents { get; set; } + + [Output] + public ITaskItem[] ContainedTypeLibraries { get; set; } + + [Output] + public ITaskItem[] ContainedLooseTlbFiles { get; set; } + + [Output] + public ITaskItem[] ContainedLooseEtcFiles { get; set; } + + #endregion + } + +#endif + + internal interface IResolveNativeReferenceTaskConract + { + #region Properties + + ITaskItem[] NativeReferences { get; set; } + string[] AdditionalSearchPaths { get; set; } + ITaskItem[] ContainingReferenceFiles { get; set; } + ITaskItem[] ContainedPrerequisiteAssemblies { get; set; } + ITaskItem[] ContainedComComponents { get; set; } + ITaskItem[] ContainedTypeLibraries { get; set; } + ITaskItem[] ContainedLooseTlbFiles { get; set; } + ITaskItem[] ContainedLooseEtcFiles { get; set; } + + #endregion + } } diff --git a/src/Tasks/TaskRequiresFramework.cs b/src/Tasks/TaskRequiresFramework.cs new file mode 100644 index 00000000000..e681eb903b5 --- /dev/null +++ b/src/Tasks/TaskRequiresFramework.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +using System; + +namespace Microsoft.Build.Tasks +{ +#if NETFRAMEWORK + [Obsolete("The class should not be used in .Net Framework.", true)] +#endif + public abstract class TaskRequiresFramework : TaskExtension + { + internal TaskRequiresFramework(string taskName) => TaskName = taskName; + + private string TaskName { get; set; } + +#if !NETFRAMEWORK + /// + /// Task entry point. + /// + /// + public override bool Execute() + { + Log.LogErrorWithCodeFromResources("TaskRequiresFrameworkFailure", TaskName); + return false; + } +#endif + } +} diff --git a/src/Tasks/UnregisterAssembly.cs b/src/Tasks/UnregisterAssembly.cs index 4c297df27fd..6721625deb5 100644 --- a/src/Tasks/UnregisterAssembly.cs +++ b/src/Tasks/UnregisterAssembly.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if FEATURE_APPDOMAIN +#if NETFRAMEWORK && FEATURE_APPDOMAIN using System; #if DEBUG @@ -14,19 +14,23 @@ using System.Threading; using System.Runtime.InteropServices.ComTypes; -using Microsoft.Build.Framework; using Microsoft.Build.Shared; using Microsoft.Build.Shared.FileSystem; +#endif + +using Microsoft.Build.Framework; #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK && FEATURE_APPDOMAIN + /// /// Registers a managed assembly for COM interop (equivalent of regasm.exe functionality, but this code /// doesn't actually call the exe). /// - public class UnregisterAssembly : AppDomainIsolatedTaskExtension + public class UnregisterAssembly : AppDomainIsolatedTaskExtension, IUnregisterAssemblyTaskContract { #region Properties @@ -289,5 +293,37 @@ private bool Unregister(string assemblyPath, string typeLibPath) private const string unregisteringLockName = "MSBUILD_V_3_5_UNREGISTER_LOCK"; #endregion } -} + +#elif !NETFRAMEWORK + + public sealed class UnregisterAssembly : TaskRequiresFramework, IUnregisterAssemblyTaskContract + { + public UnregisterAssembly() + : base(nameof(UnregisterAssembly)) + { + } + + #region Properties + + public ITaskItem[] Assemblies { get; set; } + + public ITaskItem[] TypeLibFiles { get; set; } + + public ITaskItem AssemblyListFile { get; set; } + + #endregion + } + #endif + + public interface IUnregisterAssemblyTaskContract + { + #region Properties + + ITaskItem[] Assemblies { get; set; } + ITaskItem[] TypeLibFiles { get; set; } + ITaskItem AssemblyListFile { get; set; } + + #endregion + } +} diff --git a/src/Tasks/UpdateManifest.cs b/src/Tasks/UpdateManifest.cs index 0e9e78bef9c..109f7ee732c 100644 --- a/src/Tasks/UpdateManifest.cs +++ b/src/Tasks/UpdateManifest.cs @@ -2,17 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Build.Framework; + +#if NETFRAMEWORK using Microsoft.Build.Tasks.Deployment.ManifestUtilities; using Microsoft.Build.Utilities; +#endif #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK + /// /// Updates selected properties in a manifest and resigns. /// - public class UpdateManifest : Task + public class UpdateManifest : Task, IUpdateManifestTaskContract { [Required] public string ApplicationPath { get; set; } @@ -35,4 +40,44 @@ public override bool Execute() return true; } } + +#else + + public sealed class UpdateManifest : TaskRequiresFramework, IUpdateManifestTaskContract + { + public UpdateManifest() + : base(nameof(UpdateManifest)) + { + } + + #region Properties + + public string ApplicationPath { get; set; } + + public string TargetFrameworkVersion { get; set; } + + public ITaskItem ApplicationManifest { get; set; } + + public ITaskItem InputManifest { get; set; } + + [Output] + public ITaskItem OutputManifest { get; set; } + + #endregion + } + +#endif + + internal interface IUpdateManifestTaskContract + { + #region Properties + + string ApplicationPath { get; set; } + string TargetFrameworkVersion { get; set; } + ITaskItem ApplicationManifest { get; set; } + ITaskItem InputManifest { get; set; } + ITaskItem OutputManifest { get; set; } + + #endregion + } } diff --git a/src/Tasks/WinMDExp.cs b/src/Tasks/WinMDExp.cs index 28e2662c997..280b5dcb55c 100644 --- a/src/Tasks/WinMDExp.cs +++ b/src/Tasks/WinMDExp.cs @@ -1,21 +1,28 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#if NETFRAMEWORK using System; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Text; -using Microsoft.Build.Framework; + using Microsoft.Build.Shared; +#endif + +using System.Diagnostics.CodeAnalysis; + +using Microsoft.Build.Framework; #nullable disable namespace Microsoft.Build.Tasks { +#if NETFRAMEWORK + /// /// Exports a managed assembly to a windows runtime metadata. /// - public class WinMDExp : ToolTaskExtension + public class WinMDExp : ToolTaskExtension, IWinMDExpTaskContract { #region Properties @@ -274,4 +281,66 @@ protected override bool SkipTaskExecution() } #endregion } + +#else + + public sealed class WinMDExp : TaskRequiresFramework, IWinMDExpTaskContract + { + public WinMDExp() + : base(nameof(WinMDExp)) + { + } + + #region Properties + + public ITaskItem[] References { get; set; } + + public string DisabledWarnings { get; set; } + + public string InputDocumentationFile { get; set; } + + public string OutputDocumentationFile { get; set; } + + public string InputPDBFile { get; set; } + + public string OutputPDBFile { get; set; } + + public string WinMDModule { get; set; } + + [Output] + public string OutputWindowsMetadataFile { get; set; } + + public string SdkToolsPath { get; set; } + + [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "UTF", Justification = "Not worth breaking customers because of case correction")] + public bool UTF8Output { get; set; } + + public bool TreatWarningsAsErrors { get; set; } + + public string AssemblyUnificationPolicy { get; set; } + + #endregion + } + +#endif + + internal interface IWinMDExpTaskContract + { + #region Properties + + ITaskItem[] References { get; set; } + string DisabledWarnings { get; set; } + string InputDocumentationFile { get; set; } + string OutputDocumentationFile { get; set; } + string InputPDBFile { get; set; } + string OutputPDBFile { get; set; } + string WinMDModule { get; set; } + string OutputWindowsMetadataFile { get; set; } + string SdkToolsPath { get; set; } + bool UTF8Output { get; set; } + bool TreatWarningsAsErrors { get; set; } + string AssemblyUnificationPolicy { get; set; } + + #endregion + } }