diff --git a/.tools/net.r_eg.DllExport.targets b/.tools/net.r_eg.DllExport.targets
index 14ac089..e21c3c6 100644
--- a/.tools/net.r_eg.DllExport.targets
+++ b/.tools/net.r_eg.DllExport.targets
@@ -136,6 +136,7 @@
$(DllExportVSRoot)VC\bin
$(DllExportVSBin)
$(TargetFrameworkVersion)
+ $(TargetFrameworkIdentifier)
$(DllExportILAsmCustomPath);$(TargetFrameworkSDKToolsDirectory)
$(NoDllExportsForAnyCpu)
true
@@ -177,6 +178,7 @@
LibToolPath="$(DllExportLibToolPath)"
LibToolDllPath="$(DllExportLibToolDllPath)"
TargetFrameworkVersion="$(DllExportTargetFrameworkVersion)"
+ TargetFrameworkIdentifier="$(DllExportTargetFrameworkIdentifier)"
SdkPath="$(DllExportSdkPath)"
SkipOnAnyCpu="$(DllExportSkipOnAnyCpu)"
OrdinalsBase="$(DllExportOrdinalsBase)"
diff --git a/src/DllExport/Activator/DllExportActivatorTask.cs b/src/DllExport/Activator/DllExportActivatorTask.cs
index 1d1b216..7ea2af3 100644
--- a/src/DllExport/Activator/DllExportActivatorTask.cs
+++ b/src/DllExport/Activator/DllExportActivatorTask.cs
@@ -52,6 +52,12 @@ public string TargetFrameworkVersion
set => exportTask.TargetFrameworkVersion = value;
}
+ public string TargetFrameworkIdentifier
+ {
+ get => exportTask.TargetFrameworkIdentifier;
+ set => exportTask.TargetFrameworkIdentifier = value;
+ }
+
public string Platform
{
get => exportTask.Platform;
diff --git a/src/DllExport/Activator/ExportTaskImplementation.cs b/src/DllExport/Activator/ExportTaskImplementation.cs
index 7912b24..e37a973 100644
--- a/src/DllExport/Activator/ExportTaskImplementation.cs
+++ b/src/DllExport/Activator/ExportTaskImplementation.cs
@@ -21,7 +21,7 @@
namespace net.r_eg.DllExport.Activator
{
- using TCallbackTool = Func;
+ using TCallbackTool = Func;
public class ExportTaskImplementation: IInputValues, IServiceContainer, IServiceProvider where TTask : IDllExportTask, ITask
{
@@ -58,6 +58,8 @@ public CpuPlatform Cpu
public string TargetFrameworkVersion { get; set; }
+ public string TargetFrameworkIdentifier { get; set; }
+
public bool? SkipOnAnyCpu { get; set; }
public DebugType EmitDebugSymbols
@@ -511,7 +513,7 @@ private TCallbackTool GetGetToolPathInternal(string methodName)
.MakeGenericMethod(targetDotNetFrameworkVersionType)
.Invoke(null, new object[] { method });
- Func getToolPath = ((n, v) =>
+ string getToolPath(string n, int v)
{
try
{
@@ -521,22 +523,33 @@ private TCallbackTool GetGetToolPathInternal(string methodName)
{
return null;
}
- });
+ }
- Func getNum = delegate(string version) {
+ int getNum(string version)
+ {
return (int)Enum.Parse(targetDotNetFrameworkVersionType, version);
- };
+ }
+
+ const string _V_LATEST = "Latest";
- return ((version, toolName) =>
+ return (ident, version, toolName) =>
{
int num;
// TargetDotNetFrameworkVersion Enumeration: https://msdn.microsoft.com/en-us/library/ms126273.aspx
- try {
- num = getNum($"Version{version.Major}{version.Minor}");
+ try
+ {
+ num = getNum
+ (
+ ident == TfmIdentifier.NETFramework
+ ? $"{nameof(Version)}{version.Major}{version.Minor}"
+ : nameof(Version) + _V_LATEST // latest released for current env
+ );
}
- catch(ArgumentException) {
- num = getNum("VersionLatest"); // try with latest released version
+ catch(ArgumentException)
+ {
+ if(ident != TfmIdentifier.NETFramework) throw;
+ num = getNum(nameof(Version) + _V_LATEST);
}
string path = getToolPath(toolName, num);
@@ -564,7 +577,7 @@ private TCallbackTool GetGetToolPathInternal(string methodName)
return null;
}
return path;
- });
+ };
}
protected Type GetToolLocationHelperTypeFromRegsitry()
@@ -708,40 +721,50 @@ private bool ValidateToolPath(string toolFileName, string currentValue, TCallbac
private bool TryToGetToolDirForFxVersion(string toolFileName, TCallbackTool getToolPath, ref string toolDirectory)
{
- Version frameworkVersion = GetFrameworkVersion();
- if(frameworkVersion.Major < 1) {
+ Version tfmVersion = GetTfmVersion(TargetFrameworkVersion);
+ TfmIdentifier tfmIdent = GetTfmIdentifier(TargetFrameworkIdentifier);
+
+ if(tfmIdent == TfmIdentifier.NETFramework && tfmVersion.Major < 1)
+ {
return false;
}
if(getToolPath != null)
{
- string path = getToolPath(frameworkVersion, toolFileName);
+ string path = getToolPath(tfmIdent, tfmVersion, toolFileName);
if(path != null && File.Exists(path))
{
toolDirectory = Path.GetDirectoryName(path);
return true;
}
- this._ActualTask.Log.LogError(string.Format(Resources.ToolLocationHelperTypeName_could_not_find_1, (object)"Microsoft.Build.Utilities.ToolLocationHelper", (object)toolFileName));
+ _ActualTask.Log.LogError(string.Format(Resources.ToolLocationHelperTypeName_could_not_find_1, "Microsoft.Build.Utilities.ToolLocationHelper", toolFileName));
return false;
}
- if(!(frameworkVersion >= ExportTaskImplementation._VersionUsingToolLocationHelper))
+
+ // TODO
+ if(!(tfmVersion >= _VersionUsingToolLocationHelper))
{
return false;
}
- this._ActualTask.Log.LogError(string.Format(Resources.Cannot_get_a_reference_to_ToolLocationHelper, (object)"Microsoft.Build.Utilities.ToolLocationHelper"));
+
+ _ActualTask.Log.LogError(string.Format(Resources.Cannot_get_a_reference_to_ToolLocationHelper, "Microsoft.Build.Utilities.ToolLocationHelper"));
return false;
}
- private Version GetFrameworkVersion()
+ private Version GetTfmVersion(string frameworkVersion)
{
- string frameworkVersion = this.TargetFrameworkVersion;
- if(!ExportTaskImplementation.PropertyHasValue(frameworkVersion))
- {
- return (Version)null;
- }
+ if(!PropertyHasValue(frameworkVersion)) return null;
return new Version(frameworkVersion.TrimStart('v', 'V'));
}
+ private TfmIdentifier GetTfmIdentifier(string raw) => raw?.Trim(' ', '.').ToLowerInvariant() switch
+ {
+ "netcoreapp" => TfmIdentifier.NETCoreApp,
+ "netstandard" => TfmIdentifier.NETStandard,
+ null or "" or "netframework" => TfmIdentifier.NETFramework,
+ _ => TfmIdentifier.NETFramework, //TODO
+ };
+
// FIXME: two different places (see IlDasm.Run) for the same thing ! be careful
private bool ValidateSdkPath()
{
diff --git a/src/DllExport/Activator/IDllExportTask.cs b/src/DllExport/Activator/IDllExportTask.cs
index 2db9d0b..1946f66 100644
--- a/src/DllExport/Activator/IDllExportTask.cs
+++ b/src/DllExport/Activator/IDllExportTask.cs
@@ -13,27 +13,14 @@ namespace net.r_eg.DllExport.Activator
{
public interface IDllExportTask: IInputValues, IServiceProvider
{
- TaskLoggingHelper Log
- {
- get;
- }
+ TaskLoggingHelper Log { get; }
- bool? SkipOnAnyCpu
- {
- get;
- set;
- }
+ bool? SkipOnAnyCpu { get; set; }
- string TargetFrameworkVersion
- {
- get;
- set;
- }
+ string TargetFrameworkVersion { get; set; }
- string Platform
- {
- get;
- set;
- }
+ string TargetFrameworkIdentifier { get; set; }
+
+ string Platform { get; set; }
}
}
diff --git a/src/DllExport/Activator/TfmIdentifier.cs b/src/DllExport/Activator/TfmIdentifier.cs
new file mode 100644
index 0000000..4afba4a
--- /dev/null
+++ b/src/DllExport/Activator/TfmIdentifier.cs
@@ -0,0 +1,29 @@
+/*!
+ * Copyright (c) Robert Giesecke
+ * Copyright (c) Denis Kuzmin github/3F
+ * Copyright (c) DllExport contributors https://github.com/3F/DllExport/graphs/contributors
+ * Licensed under the MIT License (MIT).
+ * See accompanying LICENSE.txt file or visit https://github.com/3F/DllExport
+*/
+
+namespace net.r_eg.DllExport.Activator
+{
+ internal enum TfmIdentifier
+ {
+ ///
+ /// TargetFrameworkIdentifier = ".NETFramework"
+ /// or TargetFrameworkIdentifier = "" (MSBuild 15 or less)
+ ///
+ NETFramework,
+
+ ///
+ /// TargetFrameworkIdentifier = ".NETStandard"
+ ///
+ NETStandard,
+
+ ///
+ /// TargetFrameworkIdentifier = ".NETCoreApp"
+ ///
+ NETCoreApp
+ }
+}
diff --git a/src/DllExport/Wizard/UI/SimpleConfFormater.cs b/src/DllExport/Wizard/UI/SimpleConfFormater.cs
index 906c127..0038afc 100644
--- a/src/DllExport/Wizard/UI/SimpleConfFormater.cs
+++ b/src/DllExport/Wizard/UI/SimpleConfFormater.cs
@@ -52,6 +52,7 @@ public string Parse(IProject prj)
"TargetFramework",
"TargetFrameworks",
"TargetFrameworkVersion",
+ "TargetFrameworkIdentifier",
"RootNamespace",
"AssemblyName",
"DebugType",