Skip to content

Commit

Permalink
Fixes #159 the first phase of the build when restoring
Browse files Browse the repository at this point in the history
  • Loading branch information
3F committed Jun 7, 2020
1 parent 61defd6 commit 5c49c6c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
45 changes: 32 additions & 13 deletions Wizard/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,6 @@ protected void AddDllExportLib()
{
string dxpTarget = AddImport(Config.Wizard.DxpTarget, true, METALIB_PK_TOKEN);

var lib = MetaLib(false);
Log.send(this, $"Add meta library: '{lib}'", Message.Level.Info);

XProject.AddReference(
$"DllExport, PublicKeyToken={METALIB_PK_TOKEN}",
MakeBasePath(lib),
false,
null,
false
);

if(!string.IsNullOrWhiteSpace(Config.Wizard.PkgVer)
&& XProject.GetFirstPackageReference(UserConfig.PKG_ID).parentItem == null)
{
Expand All @@ -547,19 +536,21 @@ protected void AddDllExportLib()
);
}

AddRestoreDxp(
var rst = AddRestoreDxp(
MSBuildTargets.DXP_PKG_R,
$"'$({MSBuildTargets.DXP_MAIN_FLAG})' != 'true' Or !Exists('{dxpTarget}')",
UserConfig.MGR_FILE
);

AddRestoreFirstPhase(rst, dxpTarget);

AddDynRestore(
MSBuildTargets.DXP_R_DYN,
$"'$({MSBuildTargets.DXP_MAIN_FLAG})' != 'true' And '$(DllExportRPkgDyn)' != 'false'"
);
}

protected void AddRestoreDxp(string name, string condition, string manager)
protected ProjectTargetElement AddRestoreDxp(string name, string condition, string manager)
{
var target = AddTarget(name);
target.BeforeTargets = "PrepareForBuild";
Expand All @@ -583,6 +574,34 @@ protected void AddRestoreDxp(string name, string condition, string manager)
}
taskExec.SetParameter("Command", $".\\{manager} {args} -action Restore");
taskExec.SetParameter("WorkingDirectory", $"$({MSBuildProperties.SLN_DIR})");

return target;
}

// https://github.com/3F/DllExport/issues/159
protected void AddRestoreFirstPhase(ProjectTargetElement target, string dxpTarget)
{
var t = target.AddTask("MSBuild");
t.Condition = $"'$({MSBuildTargets.DXP_MAIN_FLAG})' != 'true'";
t.SetParameter("Projects", dxpTarget);
t.SetParameter("Targets", "DllExportMetaXBaseTarget");
t.SetParameter("Properties", "TargetFramework=$(TargetFramework)");
t.AddOutputProperty("TargetOutputs", "DllExportMetaXBase");

var lib = MetaLib(false);
Log.send(this, $"Add meta library: '{lib}'", Message.Level.Info);

target.AddItemGroup().AddItem
(
"Reference",
$"DllExport, PublicKeyToken={METALIB_PK_TOKEN}",
new Dictionary<string, string>()
{
{ "HintPath", MakeBasePath(lib) },
{ "Private", false.ToString() },
{ "SpecificVersion", false.ToString() }
}
);
}

// https://github.com/3F/DllExport/issues/62#issuecomment-353785676
Expand Down
2 changes: 1 addition & 1 deletion tools/net.r_eg.DllExport.targets
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<UsingTask TaskName="RGiesecke.DllExport.MSBuild.DllExportAppDomainIsolatedTask" AssemblyFile="RGiesecke.DllExport.MSBuild.dll" />

<!-- To support multi-targeting in SDK-Based projects: netstandard2.0;net40;... -->
<Target Name="DllExportMetaXBaseTarget" BeforeTargets="GenerateTargetFrameworkMonikerAttribute">
<Target Name="DllExportMetaXBaseTarget" BeforeTargets="GenerateTargetFrameworkMonikerAttribute" Inputs="$(TargetFramework)" Outputs="$(DllExportMetaXBase)">
<PropertyGroup>
<IsNetCoreBased Condition="$(TargetFramework.StartsWith('netc')) Or $(TargetFramework.StartsWith('nets'))">true</IsNetCoreBased>
<DllExportMetaXBase Condition="$(IsNetCoreBased) == 'true'">$(DllExportDirMetaCore)</DllExportMetaXBase>
Expand Down

0 comments on commit 5c49c6c

Please sign in to comment.