Background: We have components with referencies. The dependencies of a component to another is stored in xml files.
Our buildtool is msbuild with custom applications and custom msbuild tasks. An application starts the compilation of the components in the right order.
We implemented a custom task 'CustomResolveReferences' to add the dependencies based on the xml files to the ITaskItem[] References.
<Target Name="BeforeResolveReferences">
<CustomResolveReferences ProjectPath="$(ProjectDir)" Configuration="$(Configuration)">
<Output TaskParameter="References" ItemName="Reference"/>
</CustomResolveReferences>
</Target>
Problem: That works perfectly to build the component in VS. But the designer of VS2008 and VS2005 can't find the dynamically added references. So we get errors like that when we want to open a form in designer:
Could not load file or assembly 'XwpMetaData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3a194cb621ebd9ba' or one of its dependencies. Das System kann die angegebene Datei nicht finden.
Call Stack:
at System.Signature._GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, IntPtr fieldHandle, IntPtr methodHandle, IntPtr declaringTypeHandle)
at System.Signature.GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandle fieldHandle, RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle)
at System.Signature..ctor(RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle)
at System.Reflection.RuntimeConstructorInfo.get_Signature()
at System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
at System.RuntimeType.FilterApplyMethodBaseInfo(MethodBase methodBase, BindingFlags bindingFlags, CallingConventions callConv, Type[] argumentTypes)
at System.RuntimeType.GetConstructorCandidates(String name, BindingFlags bindingAttr, CallingConventions callConv, Type[] types, Boolean allowPrefixLookup)
at System.RuntimeType.GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
at System.ComponentModel.BindingList`1.get_ItemTypeHasDefaultConstructor()
at System.ComponentModel.BindingList`1.Initialize()
at System.ComponentModel.BindingList`1..ctor()
Special is aswell that under References in VS the dynamically added references are not listed. But they are loaded correctly during build, because the build works.
More Information: Part of the code in the custom task 'CustomResolveReferences':
public class CustomResolveReferences : Task
{
private ITaskItem[] references = new ITaskItem[0];
//...
[Output]
public ITaskItem[] References
{
get { return references; }
}
//...
public override bool Execute()
{
//...
List<TaskItem> referenceList = new List<TaskItem>();
//... for every dependency
TaskItem item = new TaskItem(filePath);
item.SetMetadata("Private", "False");
referenceList.Add(item);
//...
references = referenceList.ToArray();
}
}
More about
BeforeResolveReferences target.
Question: From where does the designer get the information about additional paths?
Is there an other variable except References which I have to set, that it works?
Has anyone some Ideas?
Thanks a lot.