Skip to content

Commit

Permalink
Merge pull request #13 from nike4613/main
Browse files Browse the repository at this point in the history
Use `IntermediateOutputPath` instead of blindly guessing that it's `obj/`
  • Loading branch information
aelij authored Nov 22, 2022
2 parents 83db587 + 2136302 commit 8ee9391
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/Build/IgnoresAccessChecksToGenerator.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
<UsingTask AssemblyFile="$(_IACTG_TaskAssembly)" TaskName="IgnoresAccessChecksToGenerator.Tasks.PublicizeInternals" />

<Target Name="IgnoresAccessChecksToGenerator" AfterTargets="AfterResolveReferences">
<PublicizeInternals SourceReferences="@(ReferencePath)" AssemblyNames="$(InternalsAssemblyNames)" ExcludeTypeNames="$(InternalsAssemblyExcludeTypeNames)" UseEmptyMethodBodies="$(InternalsAssemblyUseEmptyMethodBodies)">
<PublicizeInternals
SourceReferences="@(ReferencePath)"
AssemblyNames="$(InternalsAssemblyNames)"
ExcludeTypeNames="$(InternalsAssemblyExcludeTypeNames)"
UseEmptyMethodBodies="$(InternalsAssemblyUseEmptyMethodBodies)"
IntermediateOutputDirectory="$(IntermediateOutputPath)">
<Output ItemName="ReferencePath" TaskParameter="TargetReferences" />
<Output ItemName="_IACTG_RemovedReferences" TaskParameter="RemovedReferences" />
<Output ItemName="Compile" TaskParameter="GeneratedCodeFiles" />
Expand All @@ -19,4 +24,4 @@
</ItemGroup>
</Target>

</Project>
</Project>
12 changes: 4 additions & 8 deletions src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class PublicizeInternals : Task
{
private static readonly char[] Semicolon = { ';' };

private readonly string _sourceDir = Directory.GetCurrentDirectory();

private readonly AssemblyResolver _resolver = new AssemblyResolver();

[Required]
Expand All @@ -22,6 +20,9 @@ public class PublicizeInternals : Task
[Required]
public string AssemblyNames { get; set; }

[Required]
public string IntermediateOutputDirectory { get; set; }

public string ExcludeTypeNames { get; set; }

public bool UseEmptyMethodBodies { get; set; } = true;
Expand All @@ -48,7 +49,7 @@ public override bool Execute()
return true;
}

var targetPath = Path.Combine(_sourceDir, "obj", "GeneratedPublicizedAssemblies");
var targetPath = Path.Combine(IntermediateOutputDirectory, "GeneratedPublicizedAssemblies");
Directory.CreateDirectory(targetPath);

GenerateAttributes(targetPath, assemblyNames);
Expand Down Expand Up @@ -175,11 +176,6 @@ private void CreatePublicAssembly(string source, string target)

private string GetFullFilePath(string path)
{
if (!Path.IsPathRooted(path))
{
path = Path.Combine(_sourceDir, path);
}

path = Path.GetFullPath(path);
return path;
}
Expand Down

0 comments on commit 8ee9391

Please sign in to comment.