From 2b89a04a63e9774995783ff3cbb54d5cbc7c66f0 Mon Sep 17 00:00:00 2001 From: "Denis Kuzmin [ GitHub/3F ]" Date: Mon, 28 Oct 2019 20:58:56 +0300 Subject: [PATCH] Basic support for the netcore-based projects. /#90 --- .gitignore | 1 + .vssbe | 36 +++++++++---- DllExport.sln | 14 +++-- Manager/batch/.compressor | 2 +- Manager/batch/Manager.bat | 9 +++- Manager/batch/tests.targets | 3 ++ MetadataCore/MetadataCore.csproj | 32 +++++++++++ {Metadata => MetadataFx}/AssemblyInfo.cs | 0 .../DllExportAttribute.cs | 0 .../MetadataFx.csproj | 0 {Metadata => MetadataFx}/key.snk | Bin RGiesecke.DllExport/Parsing/ILAsm.cs | 9 +++- RGiesecke.DllExport/Parsing/IlParser.cs | 50 +++++++++++++++++- Wizard/DllExportCfgTask.cs | 14 ++++- Wizard/IProject.cs | 3 +- Wizard/IWizardConfig.cs | 7 ++- Wizard/Project.cs | 33 +++++++++--- Wizard/Wizard.csproj | 1 + Wizard/net.r_eg.DllExport.Wizard.targets | 4 +- tools/net.r_eg.DllExport.targets | 39 +++++++++++--- 20 files changed, 221 insertions(+), 36 deletions(-) create mode 100644 MetadataCore/MetadataCore.csproj rename {Metadata => MetadataFx}/AssemblyInfo.cs (100%) rename {Metadata => MetadataFx}/DllExportAttribute.cs (100%) rename Metadata/Metadata.csproj => MetadataFx/MetadataFx.csproj (100%) rename {Metadata => MetadataFx}/key.snk (100%) diff --git a/.gitignore b/.gitignore index 938ac55..e2e7ee7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ## Specific +/MetadataCore/DllExport.xml /Configurator/ConfVersion.cs ## Ignore Visual Studio temporary files, build results, and diff --git a/.vssbe b/.vssbe index 5e3c694..dac87e4 100644 --- a/.vssbe +++ b/.vssbe @@ -91,7 +91,7 @@ "Mode": { "$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent", "Type": "Script", - "Command": "#[($(Configuration) == \"PublicRelease\") {\n #[$(cfgname = 'Release')]\n}\nelse{\n #[$(cfgname = $(Configuration))]\n}]\n\n#[$(dbin = \"bin/$(cfgname)/\")]\n\n$(revDeltaBase = \"2016/10/12\")\n$(revDeltaMin = $([System.Math]::Pow(10, 3)))\n$$(revDeltaMax = $([System.Math]::Pow(10, 5)))\n$(revDeltaMax = 65534) #[\" limit of AssemblyVersion (2^16 - 2) - i.e. 65534 max allowed \"]\n\n$(pDllExport = \"RGiesecke.DllExport\")\n$(pMeta = \"Metadata\")\n$(pNSBin = \"NSBin\")\n$(pMvsSln = \"MvsSln\")\n$(pWizard = \"Wizard\")\n$(pManager = \"Manager\")\n$(pPeViewer = \"PeViewer\")\n$(pGetNuTool = \"GetNuTool\")\n$(phMSBuild = \"hMSBuild\")\n$(pMSBuild = \"RGiesecke.DllExport.MSBuild\")\n$(odir = \"$(dbin)raw/\")\n\n#[IO delete.directory(\"$(dbin)\", true)]\n#[IO copy.directory(\"\", \"$(dbin)\", true)]", + "Command": "#[($(Configuration) == \"PublicRelease\") {\n #[$(cfgname = 'Release')]\n}\nelse{\n #[$(cfgname = $(Configuration))]\n}]\n\n#[$(dbin = \"bin/$(cfgname)/\")]\n\n$(revDeltaBase = \"2016/10/12\")\n$(revDeltaMin = $([System.Math]::Pow(10, 3)))\n$$(revDeltaMax = $([System.Math]::Pow(10, 5)))\n$(revDeltaMax = 65534) #[\" limit of AssemblyVersion (2^16 - 2) - i.e. 65534 max allowed \"]\n\n$(pDllExport = \"RGiesecke.DllExport\")\n$(pMeta = \"MetadataFx\")\n$(pMetaCore = \"MetadataCore\")\n$(pNSBin = \"NSBin\")\n$(pMvsSln = \"MvsSln\")\n$(pWizard = \"Wizard\")\n$(pManager = \"Manager\")\n$(pPeViewer = \"PeViewer\")\n$(pGetNuTool = \"GetNuTool\")\n$(phMSBuild = \"hMSBuild\")\n$(pMSBuild = \"RGiesecke.DllExport.MSBuild\")\n$(odir = \"$(dbin)raw/\")\n\n#[IO delete.directory(\"$(dbin)\", true)]\n#[IO copy.directory(\"\", \"$(dbin)\", true)]", "Command__": [ "#[($(Configuration) == \"PublicRelease\") {", " #[$(cfgname = 'Release')]", @@ -108,7 +108,8 @@ "$(revDeltaMax = 65534) #[\" limit of AssemblyVersion (2^16 - 2) - i.e. 65534 max allowed \"]", "", "$(pDllExport = \"RGiesecke.DllExport\")", - "$(pMeta = \"Metadata\")", + "$(pMeta = \"MetadataFx\")", + "$(pMetaCore = \"MetadataCore\")", "$(pNSBin = \"NSBin\")", "$(pMvsSln = \"MvsSln\")", "$(pWizard = \"Wizard\")", @@ -235,7 +236,7 @@ "Mode": { "$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent", "Type": "Script", - "Command": "#[var pVer = #[File get(\".version\")]]\n#[$(dxpPrintVersion = \"v$(pVer)\")]\n\n#[\" TODO: how about tpl ? \"]\n\n#[IO replace.Regex(\"$(pDllExport)/DllExportVersion.cs\", \"Version =.+?\\\";\", \"Version = \\\"$(pVer)\\\";\")]\n#[IO replace.Regex(\"$(pMSBuild)/DllExportVersion.cs\", \"Version =.+?\\\";\", \"Version = \\\"$(pVer)\\\";\")]\n#[IO replace.Regex(\"$(pMeta)/AssemblyInfo.cs\", \"AssemblyVersion\\(.+?\\)\", \"AssemblyVersion(\\\"$(pVer).*\\\")\")]\n\n#[var pReleaseVersion = #[File get(\".release.version\")]]\n#[$(pReleaseVersion = $(pReleaseVersion.Trim()))]\n\n#[( $(pReleaseVersion) == \"\" ) {\n #[$(partRelV = \"\")]\n #[$(pVerRel = \"$(pVer)\")]\n} else {\n #[$(partRelV = \"-$(pReleaseVersion)\")]\n #[$(pVerRel = \"$(pVer)-$(pReleaseVersion)\")]\n}]\n\n#[( $(Configuration) != \"PublicRelease\" )\n{\n #[IO replace.Regex(\"$(pWizard)/WizardVersion.cs\", \"(\\sS_NUM\\s=).+?\\\";\", \"$1 \\\"$(pVer)\\\";\")]\n #[IO replace.Regex(\"$(pWizard)/WizardVersion.cs\", \"(\\sS_REL\\s=).+?\\\";\", \"$1 \\\"$(pReleaseVersion)\\\";\")]\n}]", + "Command": "#[var pVer = #[File get(\".version\")]]\n#[$(dxpPrintVersion = \"v$(pVer)\")]\n\n#[\" TODO: how about tpl ? \"]\n\n#[IO replace.Regex(\"$(pDllExport)/DllExportVersion.cs\", \"Version =.+?\\\";\", \"Version = \\\"$(pVer)\\\";\")]\n#[IO replace.Regex(\"$(pMSBuild)/DllExportVersion.cs\", \"Version =.+?\\\";\", \"Version = \\\"$(pVer)\\\";\")]\n#[IO replace.Regex(\"$(pMeta)/AssemblyInfo.cs\", \"AssemblyVersion\\(.+?\\)\", \"AssemblyVersion(\\\"$(pVer).*\\\")\")]\n#[IO replace.Regex(\"$(pMetaCore)/$(pMetaCore).csproj\", \".+?\", \"$(pVer)\")]\n\n#[var pReleaseVersion = #[File get(\".release.version\")]]\n#[$(pReleaseVersion = $(pReleaseVersion.Trim()))]\n\n#[( $(pReleaseVersion) == \"\" ) {\n #[$(partRelV = \"\")]\n #[$(pVerRel = \"$(pVer)\")]\n} else {\n #[$(partRelV = \"-$(pReleaseVersion)\")]\n #[$(pVerRel = \"$(pVer)-$(pReleaseVersion)\")]\n}]\n\n#[( $(Configuration) != \"PublicRelease\" )\n{\n #[IO replace.Regex(\"$(pWizard)/WizardVersion.cs\", \"(\\sS_NUM\\s=).+?\\\";\", \"$1 \\\"$(pVer)\\\";\")]\n #[IO replace.Regex(\"$(pWizard)/WizardVersion.cs\", \"(\\sS_REL\\s=).+?\\\";\", \"$1 \\\"$(pReleaseVersion)\\\";\")]\n}]", "Command__": [ "#[var pVer = #[File get(\".version\")]]", "#[$(dxpPrintVersion = \"v$(pVer)\")]", @@ -245,6 +246,7 @@ "#[IO replace.Regex(\"$(pDllExport)/DllExportVersion.cs\", \"Version =.+?\\\";\", \"Version = \\\"$(pVer)\\\";\")]", "#[IO replace.Regex(\"$(pMSBuild)/DllExportVersion.cs\", \"Version =.+?\\\";\", \"Version = \\\"$(pVer)\\\";\")]", "#[IO replace.Regex(\"$(pMeta)/AssemblyInfo.cs\", \"AssemblyVersion\\(.+?\\)\", \"AssemblyVersion(\\\"$(pVer).*\\\")\")]", + "#[IO replace.Regex(\"$(pMetaCore)/$(pMetaCore).csproj\", \".+?\", \"$(pVer)\")]", "", "#[var pReleaseVersion = #[File get(\".release.version\")]]", "#[$(pReleaseVersion = $(pReleaseVersion.Trim()))]", @@ -405,7 +407,7 @@ "Mode": { "$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent", "Type": "Script", - "Command": "#[IO copy.file(\n \"$(SolutionDir)tools/*.*\", \n \"$(odir)/tools/\", \n true, \n {\"*.nuspec\"})]\n\n#[IO copy.file(\"tools/DllExport.nuspec\", \"$(odir)/DllExport.nuspec\", true)]\n#[IO replace(\"$(odir)/DllExport.nuspec\", \"$-version-$\", \"$(pVerRel)\")]\n\n#[IO copy.file({\n \"$(pDllExport)/$(OutDir:$(pDllExport))/*.*\",\n \"$(pMSBuild)/$(OutDir:$(pMSBuild))/*.*\",\n \"$(pNSBin)/$(OutDir:$(pNSBin))/*.*\",\n \"$(pWizard)/$(OutDir:$(pWizard))/*.*\",\n \"$(pPeViewer)/$(OutDir:$(pPeViewer))/*.*\"\n }, \n \"$(odir)/tools/\", true)]\n\n#[\" https://github.com/3F/DllExport/issues/36 \"]\n#[IO copy.directory(\"\", \"$(odir)/lib/net20/\", true)]\n#[IO write(\"$(odir)/lib/net20/_._\"):]\n\n#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", \n \"$(odir)/tools/raw/lib/net20/\", true)]\n \n#[IO copy.file(\"tools/build.targets\", \"$(odir)/build/net20/DllExport.targets\", true)]\n\n#[IO copy.file({ \"Readme.md\", \"3rd-party.txt\", \"changelog.txt\" }, \"$(odir)/\", true)]\n#[IO copy.file(\"LICENSE\", \"$(odir)/License.txt\", true)]\n\n#[var buildInfo = $([System.String]::Concat(\" \"))\n S_NUM: #[$(pVer)]\n \n S_REV: #[$(revBuild)]\n \n S_NUM_REV: #[$(pVer)].#[$(revBuild)]\n \n S_REL: #[$(pReleaseVersion)]\n \n bSha1: #[$(bSha1)]\n \n bName: #[$(bName)]\n \n bRevc: #[$(bRevc)]\n \n Wizard .NET: #[$(TargetFrameworkVersion:$(pWizard))]\n \n Configuration: #[$(Configuration)]\n \n Platform: #[$(Platform)]\n \n cfgname: #[$(cfgname)]\n \n revDeltaBase: #[$(revDeltaBase)]\n \n revDeltaMin: #[$(revDeltaMin)]\n \n revDeltaMax: #[$(revDeltaMax)]\n \n \n :: generated by a vsSolutionBuildEvent v#[$(vsSolutionBuildEvent)]\n]\n\n#[IO writeLine(\"$(odir)/build_info.txt\"):#[var buildInfo]]\n\n\n#[IO replace(\"$(odir)/DllExport.nuspec\", \"{build_info}\", \"$(buildInfo)\")]", + "Command": "#[IO copy.file(\n \"$(SolutionDir)tools/*.*\", \n \"$(odir)/tools/\", \n true, \n {\"*.nuspec\"})]\n\n#[IO copy.file(\"tools/DllExport.nuspec\", \"$(odir)/DllExport.nuspec\", true)]\n#[IO replace(\"$(odir)/DllExport.nuspec\", \"$-version-$\", \"$(pVerRel)\")]\n\n#[IO copy.file({\n \"$(pDllExport)/$(OutDir:$(pDllExport))/*.*\",\n \"$(pMSBuild)/$(OutDir:$(pMSBuild))/*.*\",\n \"$(pNSBin)/$(OutDir:$(pNSBin))/*.*\",\n \"$(pWizard)/$(OutDir:$(pWizard))/*.*\",\n \"$(pPeViewer)/$(OutDir:$(pPeViewer))/*.*\"\n }, \n \"$(odir)/tools/\", true)]\n\n#[\" https://github.com/3F/DllExport/issues/36 \"]\n#[IO copy.directory(\"\", \"$(odir)/lib/net20/\", true)]\n#[IO write(\"$(odir)/lib/net20/_._\"):]\n\n#[IO copy.directory(\"\", \"$(odir)/lib/netstandard2.0/\", true)]\n#[IO write(\"$(odir)/lib/netstandard2.0/_._\"):]\n\n\n#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", \"$(odir)/tools/raw/lib/net20/\", true)]\n#[IO copy.file(\"$(pMetaCore)/$(OutputPath:$(pMetaCore))*.dll\", \"$(odir)/tools/raw/lib/netstd/\", true)]\n\n#[IO copy.file(\"tools/build.targets\", \"$(odir)/build/net20/DllExport.targets\", true)]\n\n#[IO copy.file({ \"Readme.md\", \"3rd-party.txt\", \"changelog.txt\" }, \"$(odir)/\", true)]\n#[IO copy.file(\"LICENSE\", \"$(odir)/License.txt\", true)]\n\n#[var buildInfo = $([System.String]::Concat(\" \"))\n S_NUM: #[$(pVer)]\n \n S_REV: #[$(revBuild)]\n \n S_NUM_REV: #[$(pVer)].#[$(revBuild)]\n \n S_REL: #[$(pReleaseVersion)]\n \n bSha1: #[$(bSha1)]\n \n bName: #[$(bName)]\n \n bRevc: #[$(bRevc)]\n \n Wizard .NET: #[$(TargetFrameworkVersion:$(pWizard))]\n \n Configuration: #[$(Configuration)]\n \n Platform: #[$(Platform)]\n \n cfgname: #[$(cfgname)]\n \n revDeltaBase: #[$(revDeltaBase)]\n \n revDeltaMin: #[$(revDeltaMin)]\n \n revDeltaMax: #[$(revDeltaMax)]\n \n \n :: generated by a vsSolutionBuildEvent v#[$(vsSolutionBuildEvent)]\n]\n\n#[IO writeLine(\"$(odir)/build_info.txt\"):#[var buildInfo]]\n\n\n#[IO replace(\"$(odir)/DllExport.nuspec\", \"{build_info}\", \"$(buildInfo)\")]", "Command__": [ "#[IO copy.file(", " \"$(SolutionDir)tools/*.*\", ", @@ -429,9 +431,13 @@ "#[IO copy.directory(\"\", \"$(odir)/lib/net20/\", true)]", "#[IO write(\"$(odir)/lib/net20/_._\"):]", "", - "#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", ", - " \"$(odir)/tools/raw/lib/net20/\", true)]", - " ", + "#[IO copy.directory(\"\", \"$(odir)/lib/netstandard2.0/\", true)]", + "#[IO write(\"$(odir)/lib/netstandard2.0/_._\"):]", + "", + "", + "#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/*.dll\", \"$(odir)/tools/raw/lib/net20/\", true)]", + "#[IO copy.file(\"$(pMetaCore)/$(OutputPath:$(pMetaCore))*.dll\", \"$(odir)/tools/raw/lib/netstd/\", true)]", + "", "#[IO copy.file(\"tools/build.targets\", \"$(odir)/build/net20/DllExport.targets\", true)]", "", "#[IO copy.file({ \"Readme.md\", \"3rd-party.txt\", \"changelog.txt\" }, \"$(odir)/\", true)]", @@ -500,14 +506,20 @@ "Mode": { "$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent", "Type": "Script", - "Command": "#[$(IDNS = 'D3F00FF1770DED978EC774BA389F2DC9')]\n\n#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/DllExport.xml\", \n \"$(odir)/tools/raw/lib/net20/\", true)]\n \n#[IO replace.Regex(\"$(odir)/tools/raw/lib/net20/DllExport.xml\", \"$(IDNS).*F00+\", \"$(IDNS)\")]", + "Command": "#[$(IDNS = 'D3F00FF1770DED978EC774BA389F2DC9')]\n\n#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/DllExport.xml\", \n \"$(odir)/tools/raw/lib/net20/\", true)]\n\n#[IO replace.Regex(\"$(odir)/tools/raw/lib/net20/DllExport.xml\", \"$(IDNS).*F00+\", \"$(IDNS)\")]\n\n\n#[IO copy.file(\"$(pMetaCore)/$(DocumentationFile:$(pMetaCore))\", \n \"$(odir)/tools/raw/lib/netstd/\", true)]\n\n#[IO replace.Regex(\"$(odir)/tools/raw/lib/netstd/DllExport.xml\", \"$(IDNS).*F00+\", \"$(IDNS)\")]", "Command__": [ "#[$(IDNS = 'D3F00FF1770DED978EC774BA389F2DC9')]", "", "#[IO copy.file(\"$(pMeta)/$(OutDir:$(pMeta))/DllExport.xml\", ", " \"$(odir)/tools/raw/lib/net20/\", true)]", - " ", - "#[IO replace.Regex(\"$(odir)/tools/raw/lib/net20/DllExport.xml\", \"$(IDNS).*F00+\", \"$(IDNS)\")]" + "", + "#[IO replace.Regex(\"$(odir)/tools/raw/lib/net20/DllExport.xml\", \"$(IDNS).*F00+\", \"$(IDNS)\")]", + "", + "", + "#[IO copy.file(\"$(pMetaCore)/$(DocumentationFile:$(pMetaCore))\", ", + " \"$(odir)/tools/raw/lib/netstd/\", true)]", + "", + "#[IO replace.Regex(\"$(odir)/tools/raw/lib/netstd/DllExport.xml\", \"$(IDNS).*F00+\", \"$(IDNS)\")]" ] } }, @@ -832,7 +844,7 @@ "Mode": { "$type": "net.r_eg.vsSBE.Events.ModeScript, vsSolutionBuildEvent", "Type": "Script", - "Command": "#[\" v1.5 and 1.6 contains bug if used 1.2.3-alpha, 1.2.3-beta-2, 1.2.3-rc ... \"] \n##[NuGet gnt.raw(\"/t:pack /p:ngin=\\\"$(odir)\\\" /p:ngout=\\\"$(dbin)\\\"\")] \n#[IO cmd(\"tools\\\\gnt.bat /t:pack /p:ngin=\\\"$(SolutionDir)$(odir)\\\" /p:ngout=\\\"$(SolutionDir)$(dbin)\\\"\", 400)]\n\n#[( $(cfgname) != \"Debug\" )\n{\n #[($(revBuild) == \"\" || $(revBuild) ~= \"*\") {\n #[$(zipname = \"DllExport_v$(pVer)$(partRelV).zip\")]\n }\n else {\n #[$(zipname = \"DllExport_v$(pVer).$(revBuild)$(partRelV)_$(bSha1).zip\")]\n }]\n \n #[7z pack.files({ \n \"$(odir)\\\\lib\\\\net20\\\\*.*\",\n \"$(odir)\\\\tools\\\\*.*\",\n \"$(odir)\\\\tools\\\\coreclr\\\\*.*\",\n \"$(odir)\\\\tools\\\\raw\\\\lib\\\\net20\\\\*.*\",\n \"$(odir)\\\\*.*\"\n }, \n \"$(dbin)\\\\$(zipname)\", \n { \"$(odir)\\\\*.nuspec\" })]\n \n \n \n #[\" \n Offline version\n \"]\n \n #[7z pack.directory(\n \"$(dbin)raw.offline\", \n \"$(dbin)offline.$(zipname)\",\n Zip,\n Deflate,\n 1\n )]\n \n}]\n", + "Command": "#[\" v1.5 and 1.6 contains bug if used 1.2.3-alpha, 1.2.3-beta-2, 1.2.3-rc ... \"] \n##[NuGet gnt.raw(\"/t:pack /p:ngin=\\\"$(odir)\\\" /p:ngout=\\\"$(dbin)\\\"\")] \n#[IO cmd(\"tools\\\\gnt.bat /t:pack /p:ngin=\\\"$(SolutionDir)$(odir)\\\" /p:ngout=\\\"$(SolutionDir)$(dbin)\\\"\", 400)]\n\n#[( $(cfgname) != \"Debug\" )\n{\n #[($(revBuild) == \"\" || $(revBuild) ~= \"*\") {\n #[$(zipname = \"DllExport_v$(pVer)$(partRelV).zip\")]\n }\n else {\n #[$(zipname = \"DllExport_v$(pVer).$(revBuild)$(partRelV)_$(bSha1).zip\")]\n }]\n \n #[7z pack.files({ \n \"$(odir)\\\\lib\\\\net20\\\\*.*\",\n \"$(odir)\\\\lib\\\\netstandard2.0\\\\*.*\",\n \"$(odir)\\\\tools\\\\*.*\",\n \"$(odir)\\\\tools\\\\coreclr\\\\*.*\",\n \"$(odir)\\\\tools\\\\raw\\\\lib\\\\net20\\\\*.*\",\n \"$(odir)\\\\tools\\\\raw\\\\lib\\\\netstd\\\\*.*\",\n \"$(odir)\\\\*.*\"\n }, \n \"$(dbin)\\\\$(zipname)\", \n { \"$(odir)\\\\*.nuspec\" })]\n \n \n \n #[\" \n Offline version\n \"]\n \n #[7z pack.directory(\n \"$(dbin)raw.offline\", \n \"$(dbin)offline.$(zipname)\",\n Zip,\n Deflate,\n 1\n )]\n \n}]\n", "Command__": [ "#[\" v1.5 and 1.6 contains bug if used 1.2.3-alpha, 1.2.3-beta-2, 1.2.3-rc ... \"] ", "##[NuGet gnt.raw(\"/t:pack /p:ngin=\\\"$(odir)\\\" /p:ngout=\\\"$(dbin)\\\"\")] ", @@ -849,9 +861,11 @@ " ", " #[7z pack.files({ ", " \"$(odir)\\\\lib\\\\net20\\\\*.*\",", + " \"$(odir)\\\\lib\\\\netstandard2.0\\\\*.*\",", " \"$(odir)\\\\tools\\\\*.*\",", " \"$(odir)\\\\tools\\\\coreclr\\\\*.*\",", " \"$(odir)\\\\tools\\\\raw\\\\lib\\\\net20\\\\*.*\",", + " \"$(odir)\\\\tools\\\\raw\\\\lib\\\\netstd\\\\*.*\",", " \"$(odir)\\\\*.*\"", " }, ", " \"$(dbin)\\\\$(zipname)\", ", diff --git a/DllExport.sln b/DllExport.sln index 92d88bd..335d50f 100644 --- a/DllExport.sln +++ b/DllExport.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.26430.6 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGiesecke.DllExport", "RGiesecke.DllExport\RGiesecke.DllExport.csproj", "{AC6947C6-0637-429A-A5F1-54447A494E6D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "Metadata\Metadata.csproj", "{D620BC4A-50CD-48DF-8C6E-B79555260EA0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetadataFx", "MetadataFx\MetadataFx.csproj", "{D620BC4A-50CD-48DF-8C6E-B79555260EA0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGiesecke.DllExport.MSBuild", "RGiesecke.DllExport.MSBuild\RGiesecke.DllExport.MSBuild.csproj", "{9C75E9C4-5D81-4704-ADD1-F4B42B6267C8}" EndProject @@ -73,9 +73,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wizard", "Wizard\Wizard.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PeViewer", "PeViewer\PeViewer.csproj", "{BE8C8005-A6C6-41D0-9DB0-6B4B7BD1077F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvsSln", "MvsSln\MvsSln\MvsSln.csproj", "{F905DFB2-2E67-4FF7-9001-924F6F2D645D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MvsSln", "MvsSln\MvsSln\MvsSln.csproj", "{F905DFB2-2E67-4FF7-9001-924F6F2D645D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvsSlnTest", "MvsSln\MvsSlnTest\MvsSlnTest.csproj", "{EC0CA220-39EC-41E5-B9D6-88D8F860F979}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MvsSlnTest", "MvsSln\MvsSlnTest\MvsSlnTest.csproj", "{EC0CA220-39EC-41E5-B9D6-88D8F860F979}" ProjectSection(ProjectDependencies) = postProject {F905DFB2-2E67-4FF7-9001-924F6F2D645D} = {F905DFB2-2E67-4FF7-9001-924F6F2D645D} EndProjectSection @@ -122,6 +122,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "batch", "batch", "{603C7C21 Manager\batch\tests.targets = Manager\batch\tests.targets EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetadataCore", "MetadataCore\MetadataCore.csproj", "{0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -183,6 +185,12 @@ Global {EC0CA220-39EC-41E5-B9D6-88D8F860F979}.PublicRelease|Any CPU.Build.0 = Release|Any CPU {EC0CA220-39EC-41E5-B9D6-88D8F860F979}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC0CA220-39EC-41E5-B9D6-88D8F860F979}.Release|Any CPU.Build.0 = Release|Any CPU + {0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}.PublicRelease|Any CPU.ActiveCfg = Release|Any CPU + {0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}.PublicRelease|Any CPU.Build.0 = Release|Any CPU + {0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F0E1861-4EC7-4125-B16A-EE95FA80FA0F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Manager/batch/.compressor b/Manager/batch/.compressor index 8ba0957..85b813d 100644 --- a/Manager/batch/.compressor +++ b/Manager/batch/.compressor @@ -92,7 +92,7 @@ var vdict = gencomb(cdict, 2, (int i) => { return char.IsLetter(cdict[i]) || cdict[i] == '_'; }); // to skip processing for: - var exvar = new[] { "__p_call", "wMgrArgs", "wSlnDir", "wPkgPath", "wMetaLib", "wDxpTarget", "wAction", "wSlnFile", "wRootPath", "ngserver" }; + var exvar = new[] { "__p_call", "wMgrArgs", "wSlnDir", "wPkgPath", "wMetaLib", "wMetaCor", "wDxpTarget", "wAction", "wSlnFile", "wRootPath", "ngserver" }; const string VNAME = "[a-z_][a-z_0-9]+"; const string VERS = "[Minified version]"; diff --git a/Manager/batch/Manager.bat b/Manager/batch/Manager.bat index 929d521..3c842f1 100644 --- a/Manager/batch/Manager.bat +++ b/Manager/batch/Manager.bat @@ -144,7 +144,8 @@ echo * Upgrade - Aggregates an Update action with additions for upgradin echo. echo -sln-dir {path} - Path to directory with .sln files to be processed. echo -sln-file {path} - Optional predefined .sln file to be processed. -echo -metalib {path} - Relative path from PkgPath to DllExport meta library. +echo -metalib {path} - Relative path to meta library. +echo -metacor {path} - Relative path to meta core library. echo -dxp-target {path} - Relative path to entrypoint wrapper of the main core. echo -dxp-version {num} - Specific version of DllExport. Where {num}: echo * Versions: 1.6.0 ... @@ -236,6 +237,11 @@ set key=!arg[%idx%]! set wMetaLib=!v! + goto continue + ) else if [!key!]==[-metacor] ( set /a "idx+=1" & call :eval arg[!idx!] v + + set wMetaCor=!v! + goto continue ) else if [!key!]==[-dxp-target] ( set /a "idx+=1" & call :eval arg[!idx!] v @@ -354,6 +360,7 @@ call :dbgprint "dxpVersion = " dxpVersion call :dbgprint "-sln-dir = " wSlnDir call :dbgprint "-sln-file = " wSlnFile call :dbgprint "-metalib = " wMetaLib +call :dbgprint "-metacor = " wMetaCor call :dbgprint "-dxp-target = " wDxpTarget call :dbgprint "-wz-target = " tWizard diff --git a/Manager/batch/tests.targets b/Manager/batch/tests.targets index b3c31f6..80bf335 100644 --- a/Manager/batch/tests.targets +++ b/Manager/batch/tests.targets @@ -96,6 +96,9 @@ + + + diff --git a/MetadataCore/MetadataCore.csproj b/MetadataCore/MetadataCore.csproj new file mode 100644 index 0000000..822e4f5 --- /dev/null +++ b/MetadataCore/MetadataCore.csproj @@ -0,0 +1,32 @@ + + + + 1.6.5 + ..\MetadataFx\ + + + + netstandard2.0 + net.r_eg.DllExport + DllExport + true + $(MetadataFxPath)key.snk + $(OutputPath)$(AssemblyName).xml + + + + false + https://github.com/3F/DllExport + git + github.com/3F/DllExport + github.com/3F/DllExport + Debug;Release;PublicRelease + + + + + + + + + diff --git a/Metadata/AssemblyInfo.cs b/MetadataFx/AssemblyInfo.cs similarity index 100% rename from Metadata/AssemblyInfo.cs rename to MetadataFx/AssemblyInfo.cs diff --git a/Metadata/DllExportAttribute.cs b/MetadataFx/DllExportAttribute.cs similarity index 100% rename from Metadata/DllExportAttribute.cs rename to MetadataFx/DllExportAttribute.cs diff --git a/Metadata/Metadata.csproj b/MetadataFx/MetadataFx.csproj similarity index 100% rename from Metadata/Metadata.csproj rename to MetadataFx/MetadataFx.csproj diff --git a/Metadata/key.snk b/MetadataFx/key.snk similarity index 100% rename from Metadata/key.snk rename to MetadataFx/key.snk diff --git a/RGiesecke.DllExport/Parsing/ILAsm.cs b/RGiesecke.DllExport/Parsing/ILAsm.cs index 3b9568f..fe51441 100644 --- a/RGiesecke.DllExport/Parsing/ILAsm.cs +++ b/RGiesecke.DllExport/Parsing/ILAsm.cs @@ -108,8 +108,13 @@ private int Run(string outputFile, string ilSuffix, CpuPlatform cpu) while(File.Exists(str1)); File.Move(this.InputValues.InputFileName, str1); } - try - { + + // https://github.com/3F/coreclr/blob/05afa4f81fdf671429b54467c64d65cde6b5fadc/src/debug/ildbsymlib/symwrite.cpp#L308 + // Due to possible incorrect ISymUnmanagedWriter when exists initial pdb data for non-modified asm. + // \- Part of https://github.com/3F/DllExport/issues/90 + File.Delete(Path.ChangeExtension(InputValues.InputFileName, ".pdb")); + + try { return this.RunCore(cpu, outputFile, ressourceParam, ilSuffix); } finally diff --git a/RGiesecke.DllExport/Parsing/IlParser.cs b/RGiesecke.DllExport/Parsing/IlParser.cs index 1ed2e4e..31cfe5a 100644 --- a/RGiesecke.DllExport/Parsing/IlParser.cs +++ b/RGiesecke.DllExport/Parsing/IlParser.cs @@ -237,6 +237,9 @@ public IEnumerable GetLines(CpuPlatform cpu) } } } + + EmitMSCorlib(stringList2, state); + stopwatch1.Stop(); this.GetNotifier().Notify(-2, "EXPPERF02", Resources.Parsing_0_lines_of_IL_took_1_ms_, (object)stringList1.Count, (object)stopwatch1.ElapsedMilliseconds); if(this.ProfileActions) @@ -246,7 +249,8 @@ public IEnumerable GetLines(CpuPlatform cpu) this.GetNotifier().Notify(-1, "EXPPERF03", Resources.Parsing_action_0_took_1_ms, (object)keyValuePair.Key, (object)keyValuePair.Value.Milliseconds); } } - return (IEnumerable)stringList2; + + return stringList2; } } @@ -255,6 +259,50 @@ internal IDllExportNotifier GetNotifier() return this.ServiceProvider.GetService(); } + /// + /// Read my note in https://github.com/3F/DllExport/issues/90 + /// + /// .assembly extern 'netstandard' + /// ... ^^^^^^^^^^^ + /// + /// .class public auto ansi beforefieldinit ... + /// extends[mscorlib] System.Object + /// ^^^^^^^^ + /// ... + /// call instance void [mscorlib]System.Object::.ctor() + /// ^^^^^^^^ + /// + /// + /// + /// + private bool EmitMSCorlib(List il, ParserStateValues state) + { + if(state.ExternalAssemlyDeclarations.Count < 1) { + return false; + } + + const string _EASM = "mscorlib"; + + if(state.ExternalAssemlyDeclarations.Any(x => x.AssemblyName == _EASM)) { + return false; + } + + il.InsertRange + ( + state.ExternalAssemlyDeclarations[0].InputLineIndex, + new [] + { + $".assembly extern '{_EASM}'", + "{", + " .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) ", + " .ver 4:0:0:0", + "}" + } + ); + + return true; + } + private HashSet GetMethodAttributes() { string str = (this.InputValues.MethodAttributes ?? "").Trim(); diff --git a/Wizard/DllExportCfgTask.cs b/Wizard/DllExportCfgTask.cs index 70c19ee..01fe90b 100644 --- a/Wizard/DllExportCfgTask.cs +++ b/Wizard/DllExportCfgTask.cs @@ -82,7 +82,7 @@ public string PkgPath private string _pkgPath; /// - /// Relative path from PkgPath to DllExport meta library. + /// Relative path to meta library. /// [Required] public string MetaLib @@ -92,6 +92,17 @@ public string MetaLib } private string _metaLib; + /// + /// Relative path to meta core library. + /// + [Required] + public string MetaCor + { + get => _metacor; + set => _metacor = value.FilePathFormat(); + } + private string _metacor; + /// /// Path to .targets file of the DllExport. /// @@ -286,6 +297,7 @@ private void PrintKeys(Message.Level level) LSender.Send(this, $"SlnFile: '{SlnFile}'", level); LSender.Send(this, $"PkgPath: '{PkgPath}'", level); LSender.Send(this, $"MetaLib: '{MetaLib}'", level); + LSender.Send(this, $"MetaCor: '{MetaCor}'", level); LSender.Send(this, $"MgrArgs: '{MgrArgs}'", level); LSender.Send(this, $"DxpTarget: '{DxpTarget}'", level); LSender.Send(this, $"RootPath: '{RootPath}'", level); diff --git a/Wizard/IProject.cs b/Wizard/IProject.cs index cda3a31..5fb2c2a 100644 --- a/Wizard/IProject.cs +++ b/Wizard/IProject.cs @@ -91,8 +91,9 @@ public interface IProject /// Returns fullpath to meta library for current project. /// /// Will return unevaluated value if false. + /// netfx-based or netcore-based meta lib. /// - string MetaLib(bool evaluate); + string MetaLib(bool evaluate, bool corlib = false); /// /// To recover references with project file. diff --git a/Wizard/IWizardConfig.cs b/Wizard/IWizardConfig.cs index 42ca9d1..5db5739 100644 --- a/Wizard/IWizardConfig.cs +++ b/Wizard/IWizardConfig.cs @@ -42,10 +42,15 @@ public interface IWizardConfig string PkgPath { get; } /// - /// Relative path from PkgPath to DllExport meta library. + /// Relative path to meta library. /// string MetaLib { get; } + /// + /// Relative path to meta core library. + /// + string MetaCor { get; } + /// /// Path to .targets file of the DllExport. /// diff --git a/Wizard/Project.cs b/Wizard/Project.cs index cebc692..5b5c813 100644 --- a/Wizard/Project.cs +++ b/Wizard/Project.cs @@ -186,21 +186,26 @@ protected ISender Log /// Returns fullpath to meta library for current project. /// /// Will return unevaluated value if false. + /// netfx-based or netcore-based meta lib. /// - public virtual string MetaLib(bool evaluate) + public virtual string MetaLib(bool evaluate, bool corlib = false) { + string mdll = GetMetaDll(corlib); + return Path.GetFullPath ( Path.Combine ( Config.Wizard.PkgPath, "gcache", - "metalib", + evaluate ? corlib ? "metacor" : "metalib" + : "$(DllExportMetaXBase)", + (evaluate && Config?.Namespace != null) ? Config.Namespace : "$(DllExportNamespace)", - (evaluate && Config?.Wizard?.MetaLib != null) ? - Path.GetFileName(Config.Wizard.MetaLib) : "$(DllExportMetaLibName)" + (evaluate && mdll != null) ? + Path.GetFileName(mdll) : "$(DllExportMetaLibName)" ) ); } @@ -372,11 +377,17 @@ protected void Save() } protected void CfgDDNS() + { + CfgDDNS(false); + CfgDDNS(true); + } + + protected void CfgDDNS(bool corlib) { Config.DDNS.setNamespace( CopyLib( - Path.Combine(Config.Wizard.PkgPath, Config.Wizard.MetaLib), - MetaLib(true) + Path.Combine(Config.Wizard.PkgPath, GetMetaDll(corlib)), + MetaLib(true, corlib) ), Config.Namespace, Config.UseCecil, @@ -740,5 +751,15 @@ private string CopyLib(string src, string dest) return dest; } + + private string GetMetaDll(bool corlib) + { + IWizardConfig cfg = Config?.Wizard; + if(cfg == null) { + return null; + } + + return corlib ? cfg.MetaCor : cfg.MetaLib; + } } } diff --git a/Wizard/Wizard.csproj b/Wizard/Wizard.csproj index 7eafd90..d118c6f 100644 --- a/Wizard/Wizard.csproj +++ b/Wizard/Wizard.csproj @@ -141,6 +141,7 @@ {f905dfb2-2e67-4ff7-9001-924f6f2d645d} MvsSln + TargetFramework=net40 {311706a5-5ed2-4006-b794-055009d8a256} diff --git a/Wizard/net.r_eg.DllExport.Wizard.targets b/Wizard/net.r_eg.DllExport.Wizard.targets index 243c6f2..dfbeded 100644 --- a/Wizard/net.r_eg.DllExport.Wizard.targets +++ b/Wizard/net.r_eg.DllExport.Wizard.targets @@ -12,6 +12,7 @@ .\ packages\DllExport tools\raw\lib\net20\DllExport.dll + tools\raw\lib\netstd\DllExport.dll tools\net.r_eg.DllExport.targets Restore @@ -41,7 +42,8 @@ SlnDir="$(wSlnDir)" SlnFile="$(wSlnFile)" PkgPath="$(wPkgPath)" - MetaLib="$(wMetaLib)" + MetaLib="$(wMetaLib)" + MetaCor="$(wMetaCor)" MgrArgs="$(wMgrArgs)" DxpTarget="$(wDxpTarget)" StoragePath="$(wStoragePath)" diff --git a/tools/net.r_eg.DllExport.targets b/tools/net.r_eg.DllExport.targets index 91455c3..124c0e0 100644 --- a/tools/net.r_eg.DllExport.targets +++ b/tools/net.r_eg.DllExport.targets @@ -1,19 +1,34 @@  + true - + + + metacor + metalib + + + + + true + $(DllExportDirMetaCore) + $(DllExportDirMetaFX) + gcache\$(DllExportMetaXBase)\$(DllExportNamespace)\ + + $(MSBuildThisFileDirectory)..\ $(VsInstallRoot)\ $(DevEnvDir)\..\..\ $(DllExportVSRoot)Common7\IDE\ - gcache\metalib\$(DllExportNamespace)\ + metalib + gcache\$(DllExportMetaXBase)\$(DllExportNamespace)\ tools\ - + $(DllExportRootPkg)$(DllExportLibPath) DllExportAttribute @@ -56,7 +71,7 @@ - - + true - + + + + + true + $(DllExportDirMetaCore) + $(DllExportDirMetaFX) + gcache\$(DllExportMetaXBase)\$(DllExportNamespace)\ + + + \ No newline at end of file