MSBuild
작업간에 Dictionary
또는 Hashtable
을 보내거나 공유하려고합니다.MSBuild 작업의 Hashtable/Dictionary 매개 변수
다음 두 가지 사용자 지정 작업, 즉 Hashtable을 생성하는 Get
과이를 사용하는 Set
이 있습니다.
Get.cs는
public class Get : Task
{
[Output]
public Hashtable Output { get; set; }
public override bool Execute()
{
Output = new Hashtable();
return true;
}
}
Set.cs는
public class Set : Task
{
[Required]
public Hashtable Output { get; set; }
public override bool Execute()
{
var items = Output.Cast<DictionaryEntry>().ToDictionary(d => d.Key.ToString(), d => d.Value.ToString());
foreach(var item in items)
{
//Do Something
}
return true;
}
}
위의 클래스는 그때 사용 Assembly.dll
으로 잘 구축 그 다음 빌드 대상 스크립트 Assembly.dll
사용자 지정 작업 가져 오기 및 설정 호출 :
MyTarget.targets
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Get" AssemblyFile=".\Assembly.dll"/>
<UsingTask TaskName="Set" AssemblyFile=".\Assembly.dll"/>
<Target Name="Get">
<Get>
<Output TaskParameter="Output" ItemName="Output" />
</Get>
<Set [email protected](Output) />
</Target>
</Project>
나는 위의 목표로 프로젝트를 빌드 할 때 MSBuild에서 다음과 같은 오류 보여줍니다
The "System.Collections.Hashtable" type of the "Output" parameter of the "Get" task is not supported by MSBuild
I가 속성에 해시 테이블 또는 사전을 사용할 수있는 방법을 사용자 지정 MSBuild 작업?