refs #59 Fixing relative paths in MSBuild obfuscation
This commit is contained in:
Родитель
0b1bbe191f
Коммит
f479c53fb9
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Confuser.Core;
|
||||
using Confuser.Core.Project;
|
||||
|
@ -10,15 +11,18 @@ namespace Confuser.MSBuild.Tasks {
|
|||
[Required]
|
||||
public ITaskItem Project { get; set; }
|
||||
|
||||
[Required, Output]
|
||||
[Required]
|
||||
public ITaskItem OutputAssembly { get; set; }
|
||||
|
||||
[Output]
|
||||
public ITaskItem[] ConfusedFiles { get; set; }
|
||||
|
||||
public override bool Execute() {
|
||||
var project = new ConfuserProject();
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(Project.ItemSpec);
|
||||
project.Load(xmlDoc);
|
||||
project.OutputDirectory = Path.GetDirectoryName(OutputAssembly.ItemSpec);
|
||||
project.OutputDirectory = Path.GetDirectoryName(Path.GetFullPath(OutputAssembly.ItemSpec));
|
||||
|
||||
var logger = new MSBuildLogger(Log);
|
||||
var parameters = new ConfuserParameters {
|
||||
|
@ -27,6 +31,9 @@ namespace Confuser.MSBuild.Tasks {
|
|||
};
|
||||
|
||||
ConfuserEngine.Run(parameters).Wait();
|
||||
|
||||
ConfusedFiles = project.Select(m => new TaskItem(Path.Combine(project.OutputDirectory, m.Path))).Cast<ITaskItem>().ToArray();
|
||||
|
||||
return !logger.HasError;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ConfuserAssemblyPath Condition="'$(MSBuildRuntimeType)' == 'Full'">$(MSBuildThisFileDirectory)\..\netframework\</ConfuserAssemblyPath>
|
||||
<ConfuserAssemblyPath Condition="'$(ConfuserAssemblyPath)' == ''">$(MSBuildThisFileDirectory)\..\netstandard\</ConfuserAssemblyPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask TaskName="Confuser.MSBuild.Tasks.CreateProjectTask"
|
||||
AssemblyFile="$(ConfuserAssemblyPath)Confuser.MSBuild.Tasks.dll" />
|
||||
<UsingTask TaskName="Confuser.MSBuild.Tasks.ConfuseTask"
|
||||
AssemblyFile="$(ConfuserAssemblyPath)Confuser.MSBuild.Tasks.dll" />
|
||||
</Project>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Project>
|
||||
<Choose>
|
||||
<When Condition="'$(MSBuildRuntimeType)' == 'Full'">
|
||||
<PropertyGroup>
|
||||
<ConfuserAssemblyPath>$(MSBuildThisFileDirectory)\..\netframework\</ConfuserAssemblyPath>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<ConfuserAssemblyPath>$(MSBuildThisFileDirectory)\..\netstandard\</ConfuserAssemblyPath>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<UsingTask TaskName="Confuser.MSBuild.Tasks.CreateProjectTask"
|
||||
AssemblyFile="$(ConfuserAssemblyPath)Confuser.MSBuild.Tasks.dll" />
|
||||
<UsingTask TaskName="Confuser.MSBuild.Tasks.ConfuseTask"
|
||||
AssemblyFile="$(ConfuserAssemblyPath)Confuser.MSBuild.Tasks.dll" />
|
||||
</Project>
|
|
@ -1,5 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)\Confuser.MSBuild.Tasks.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ConfuserKeyFile Condition="'$(ConfuserKeyFile)' == ''">$(AssemblyOriginatorKeyFile)</ConfuserKeyFile>
|
||||
<ConfuserIntermediateOutputPath Condition="'$(ConfuserIntermediateOutputPath)' == ''">$(IntermediateOutputPath)confused\</ConfuserIntermediateOutputPath>
|
||||
|
@ -21,7 +27,6 @@
|
|||
</ConfuserExDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<Target Name="ConfuserEx"
|
||||
DependsOnTargets="$(ConfuserExDependsOn)"
|
||||
BeforeTargets="PrepareForRun" />
|
||||
|
@ -60,7 +65,9 @@
|
|||
Outputs="@(IntermediateAssembly->'$(ConfuserIntermediateOutputPath)%(Filename)%(Extension)');@(IntermediateSatelliteAssembliesWithTargetPath->'$(ConfuserIntermediateOutputPath)%(TargetPath)')">
|
||||
<Confuser.MSBuild.Tasks.ConfuseTask
|
||||
Project="@(IntermediateAssembly->'$(IntermediateOutputPath)%(Filename).crproj')"
|
||||
OutputAssembly="@(IntermediateAssembly->'$(ConfuserIntermediateOutputPath)%(Filename)%(Extension)')" />
|
||||
OutputAssembly="@(IntermediateAssembly->'$(ConfuserIntermediateOutputPath)%(Filename)%(Extension)')">
|
||||
<Output TaskParameter="ConfusedFiles" ItemName="FileWrites"/>
|
||||
</Confuser.MSBuild.Tasks.ConfuseTask>
|
||||
</Target>
|
||||
|
||||
<Target Name="_ReplaceOutputWithConfusedAssemblies"
|
||||
|
|
Загрузка…
Ссылка в новой задаче