本文整理汇总了C#中Microsoft.Build.Tasks.ResolveAssemblyReference类的典型用法代码示例。如果您正苦于以下问题:C# ResolveAssemblyReference类的具体用法?C# ResolveAssemblyReference怎么用?C# ResolveAssemblyReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolveAssemblyReference类属于Microsoft.Build.Tasks命名空间,在下文中一共展示了ResolveAssemblyReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveSDKFromRefereneAssemblyLocation
private static void ResolveSDKFromRefereneAssemblyLocation(string referenceName, string expectedPath)
{
// Create the engine.
MockEngine engine = new MockEngine();
TaskItem taskItem = new TaskItem(referenceName);
taskItem.SetMetadata("SDKName", "FakeSDK, Version=1.0");
TaskItem resolvedSDK = new TaskItem(@"C:\FakeSDK");
resolvedSDK.SetMetadata("SDKName", "FakeSDK, Version=1.0");
resolvedSDK.SetMetadata("TargetedSDKConfiguration", "Debug");
resolvedSDK.SetMetadata("TargetedSDKArchitecture", "X86");
TaskItem[] assemblies = new TaskItem[] { taskItem };
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblies;
t.ResolvedSDKReferences = new ITaskItem[] { resolvedSDK };
t.SearchPaths = new String[] { @"C:\SomeOtherPlace" };
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(1, t.ResolvedFiles.Length);
Assert.Equal(0, engine.Errors);
Assert.Equal(0, engine.Warnings);
Assert.True(t.ResolvedFiles[0].ItemSpec.Equals(expectedPath, StringComparison.OrdinalIgnoreCase));
}
示例2: IgnoreVersionBasic
public void IgnoreVersionBasic()
{
MockEngine e = new MockEngine();
TaskItem item = new TaskItem("DependsOn9, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
ITaskItem[] items = new ITaskItem[]
{
item
};
string redistString = "<FileList Redist='Microsoft-Windows-CLRCoreComp-Random' >" +
"<File AssemblyName='DependsOn9' Version='9.0.0.0' PublicKeyToken='b17a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='true' />" +
"</FileList >";
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.IgnoreVersionForFrameworkReferences = true;
ExecuteRAROnItemsAndRedist(t, e, items, redistString, true);
Assert.Equal(0, e.Warnings); // "No warnings expected in this scenario."
Assert.Equal(0, e.Errors); // "No errors expected in this scenario."
Assert.Equal(1, t.ResolvedFiles.Length);
Assert.True(ContainsItem(t.ResolvedFiles, @"c:\MyComponents\misc\DependsOn9.dll")); // "Expected to find assembly, but didn't."
// Do the resolution without the metadata, expect it to not work since we should not be able to find Dependson9 version 10.0.0.0
e = new MockEngine();
item = new TaskItem("DependsOn9, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
items = new ITaskItem[]
{
item
};
redistString = "<FileList Redist='Microsoft-Windows-CLRCoreComp-Random' >" +
"<File AssemblyName='DependsOn9' Version='9.0.0.0' PublicKeyToken='b17a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='true' />" +
"</FileList >";
t = new ResolveAssemblyReference();
ExecuteRAROnItemsAndRedist(t, e, items, redistString, true);
Assert.Equal(1, e.Warnings); // "Expected one warning in this scenario."
e.AssertLogContains("MSB3257");
e.AssertLogContains("DependsOn9");
Assert.Equal(0, t.ResolvedFiles.Length);
}
示例3: Exists
public void Exists()
{
// This WriteLine is a hack. On a slow machine, the Tasks unittest fails because remoting
// times out the object used for remoting console writes. Adding a write in the middle of
// keeps remoting from timing out the object.
Console.WriteLine("Performing VersioningAndUnification.Prerequisite.StronglyNamedDependency.Exists() test");
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("DependsOnEverettSystem, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=feedbeadbadcadbe")
};
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(1, t.ResolvedDependencyFiles.Length);
Assert.Equal(0, engine.Errors);
Assert.Equal(0, engine.Warnings);
AssertNoCase
(
"System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKey, t.ResolvedDependencyFiles[0].GetMetadata("FusionName")
);
engine.AssertLogContains
(
String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByFrameworkRetarget"), "1.0.5000.0", @"C:\MyApp\v1.0\DependsOnEverettSystem.dll")
);
engine.AssertLogContains
(
String.Format(AssemblyResources.GetString("ResolveAssemblyReference.NotCopyLocalBecausePrerequisite"))
);
AssertNoCase("false", t.ResolvedDependencyFiles[0].GetMetadata("CopyLocal"));
}
示例4: Exists
public void Exists()
{
// This WriteLine is a hack. On a slow machine, the Tasks unittest fails because remoting
// times out the object used for remoting console writes. Adding a write in the middle of
// keeps remoting from timing out the object.
Console.WriteLine("Performing VersioningAndUnification.Prerequisite.SpecificVersionPrimary.Exists() test");
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("UnifyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
assemblyNames[0].SetMetadata("SpecificVersion", "true");
// Construct the app.config.
string appConfigFile = WriteAppConfig
(
" <dependentAssembly>\n" +
" <assemblyIdentity name='UnifyMe' PublicKeyToken='b77a5c561934e089' culture='neutral' />\n" +
" <bindingRedirect oldVersion='1.0.0.0' newVersion='2.0.0.0' />\n" +
" </dependentAssembly>\n"
);
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AppConfigFile = appConfigFile;
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(1, t.ResolvedFiles.Length);
AssertNoCase("UnifyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=MSIL", t.ResolvedFiles[0].GetMetadata("FusionName"));
AssertNoCase(@"{Registry:Software\Microsoft\.NetFramework,v2.0,AssemblyFoldersEx}", t.ResolvedFiles[0].GetMetadata("ResolvedFrom"));
// Cleanup.
File.Delete(appConfigFile);
}
示例5: TargetCurrentTargetFramework
public void TargetCurrentTargetFramework()
{
MockEngine e = new MockEngine();
ITaskItem[] items = new ITaskItem[]
{
new TaskItem("DependsOnOnlyv4Assemblies")
};
string redistString = "<FileList Redist='Microsoft-Windows-CLRCoreComp-Random' >" +
"<File AssemblyName='System' Version='4.0.0.0' PublicKeyToken='b77a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='true' />" +
"</FileList >";
ResolveAssemblyReference t = new ResolveAssemblyReference();
ExecuteRAROnItemsAndRedist(t, e, items, redistString, true);
Assert.Equal(0, e.Warnings); // "No warnings expected in this scenario."
Assert.Equal(0, e.Errors); // "No errors expected in this scenario."
Assert.Equal(1, t.ResolvedFiles.Length);
Assert.True(ContainsItem(t.ResolvedFiles, @"c:\MyComponents\misc\DependsOnOnlyv4Assemblies.dll")); // "Expected to find assembly, but didn't."
}
示例6: Exists
public void Exists()
{
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
// Construct the app.config.
string appConfigFile = WriteAppConfig
(
" <dependentAssembly>\n" +
" <assemblyIdentity name='UnifyMe' PublicKeyToken='b77a5c561934e089' culture='neutral' />\n" +
" <bindingRedirect oldVersion='1.0.0.0' newVersion='2.0.0.0' />\n" +
" </dependentAssembly>\n"
);
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AppConfigFile = appConfigFile;
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(1, t.ResolvedDependencyFiles.Length);
AssertNoCase("UnifyMe, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", t.ResolvedDependencyFiles[0].GetMetadata("FusionName"));
engine.AssertLogContains
(
String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAppConfig"), "1.0.0.0", appConfigFile, @"C:\MyApp\v1.0\DependsOnUnified.dll")
);
// Cleanup.
File.Delete(appConfigFile);
}
示例7: Exists
public void Exists()
{
// This WriteLine is a hack. On a slow machine, the Tasks unittest fails because remoting
// times out the object used for remoting console writes. Adding a write in the middle of
// keeps remoting from timing out the object.
Console.WriteLine("Performing VersioningAndUnification.AutoUnify.StronglyNamedDependency.Exists() test");
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
new TaskItem("DependsOnUnified, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AutoUnify = true;
bool succeeded = Execute(t);
Assert.True(succeeded);
AssertNoCase("UnifyMe, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", t.ResolvedDependencyFiles[0].GetMetadata("FusionName"));
AssertNoCase(@"C:\MyComponents\v2.0\UnifyMe.dll", t.ResolvedDependencyFiles[0].ItemSpec);
engine.AssertLogContains
(
String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnifiedDependency"), "UniFYme, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
);
engine.AssertLogContains
(
String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAutoUnify"), "1.0.0.0", @"C:\MyApp\v1.0\DependsOnUnified.dll")
);
}
示例8: SameVersionSameFrameworkDirect
public void SameVersionSameFrameworkDirect()
{
MockEngine e = new MockEngine();
ITaskItem[] items = new ITaskItem[]
{
new TaskItem("DependsOnFoo4Framework"),
};
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = e;
t.Assemblies = items;
t.TargetFrameworkMoniker = "Foo, Version=4.0";
t.TargetFrameworkMonikerDisplayName = "Foo";
t.SearchPaths = new string[] { @"c:\Frameworks\" };
Execute(t);
Assert.Equal(0, e.Warnings); // "No warnings expected in this scenario."
Assert.Equal(0, e.Errors); // "No errors expected in this scenario."
Assert.Equal(1, t.ResolvedFiles.Length);
Assert.True(ContainsItem(t.ResolvedFiles, @"c:\Frameworks\DependsOnFoo4Framework.dll")); // "Expected to find assembly, but didn't."
}
示例9: RemapAssemblyBasic
public void RemapAssemblyBasic()
{
MockEngine e = new MockEngine();
ITaskItem[] items = new ITaskItem[]
{
new TaskItem("ReferenceVersion9"),
new TaskItem("DependsOnOnlyv4Assemblies"),
new TaskItem("AnotherOne")
};
string redistString = "<FileList Redist='Microsoft-Windows-CLRCoreComp-Random' >" +
"<File AssemblyName='mscorlib' Version='4.0.0.0' PublicKeyToken='b77a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='true' />" +
"<Remap>" +
"<From AssemblyName='mscorlib' Version='9.0.0.0' PublicKeyToken='b77a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='true'>" +
" <To AssemblyName='mscorlib' Version='4.0.0.0' PublicKeyToken='b77a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='true' />" +
" </From>" +
"<From AssemblyName='DependsOnOnlyv4Assemblies'>" +
" <To AssemblyName='ReferenceVersion9' Version='9.0.0.0' PublicKeyToken='b17a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' />" +
" </From>" +
"<From AssemblyName='AnotherOne'>" +
" <To AssemblyName='ReferenceVersion9' Version='9.0.0.0' PublicKeyToken='b17a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' />" +
" </From>" +
"</Remap>" +
"</FileList >";
ResolveAssemblyReference t = new ResolveAssemblyReference();
ExecuteRAROnItemsAndRedist(t, e, items, redistString, false);
Assert.Equal(0, e.Warnings); // "Expected NO warning in this scenario."
e.AssertLogContainsMessageFromResource(resourceDelegate, "ResolveAssemblyReference.RemappedReference", "DependsOnOnlyv4Assemblies", "ReferenceVersion9, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
e.AssertLogContainsMessageFromResource(resourceDelegate, "ResolveAssemblyReference.RemappedReference", "AnotherOne", "ReferenceVersion9, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
Assert.Equal(1, t.ResolvedFiles.Length);
Assert.True(t.ResolvedFiles[0].GetMetadata("OriginalItemSpec").Equals("AnotherOne", StringComparison.OrdinalIgnoreCase));
Assert.True(t.ResolvedFiles[0].ItemSpec.Equals(@"c:\MyComponents\misc\ReferenceVersion9.dll", StringComparison.OrdinalIgnoreCase));
}
示例10: Exists
public void Exists()
{
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("UnifyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
assemblyNames[0].SetMetadata("SpecificVersion", "false");
// Construct the app.config.
string appConfigFile = WriteAppConfig
(
" <dependentAssembly>\n" +
" <assemblyIdentity name='UnifyMe' PublicKeyToken='b77a5c561934e089' culture='neutral' />\n" +
" <bindingRedirect oldVersion='1.0.0.0' newVersion='2.0.0.0' />\n" +
" </dependentAssembly>\n"
);
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AppConfigFile = appConfigFile;
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(1, t.ResolvedFiles.Length);
AssertNoCase("UnifyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=MSIL", t.ResolvedFiles[0].GetMetadata("FusionName"));
// Cleanup.
File.Delete(appConfigFile);
}
示例11: SDkNameNotInResolvedSDKListButOnSearchPath
public void SDkNameNotInResolvedSDKListButOnSearchPath()
{
// Create the engine.
MockEngine engine = new MockEngine();
TaskItem taskItem = new TaskItem(@"SDKWinMD");
taskItem.SetMetadata("SDKName", "NotInstalled, Version=1.0");
TaskItem[] assemblies = new TaskItem[] { taskItem };
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblies;
t.SearchPaths = new String[] { @"C:\FakeSDK\References" };
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(0, t.ResolvedFiles.Length);
Assert.Equal(0, engine.Errors);
Assert.Equal(1, engine.Warnings);
}
示例12: AppConfigDoesntExist
public void AppConfigDoesntExist()
{
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AppConfigFile = @"C:\MyNonexistentFolder\MyNonExistentApp.config";
bool succeeded = Execute(t);
Assert.False(succeeded);
Assert.Equal(1, engine.Errors);
}
示例13: AppConfigSpecifiedWhenAutoUnifyEqualsTrue
public void AppConfigSpecifiedWhenAutoUnifyEqualsTrue()
{
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
// Construct the app.config.
string appConfigFile = WriteAppConfig
(
" <dependentAssembly>\n" +
" <assemblyIdentity name='UnifyMe' PublicKeyToken='b77a5c561934e089' culture='neutral' />\n" +
" <bindingRedirect oldVersion='0.0.0.0-2.0.0.0' newVersion='2.0.0.0' />\n" +
" </dependentAssembly>\n"
);
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AppConfigFile = appConfigFile;
t.AutoUnify = true;
bool succeeded = Execute(t);
// With the introduction of GenerateBindingRedirects task, RAR now accepts AutoUnify and App.Config at the same time.
Assert.True(succeeded);
Assert.Equal(0, engine.Errors);
// Cleanup.
File.Delete(appConfigFile);
}
示例14: GarbageAppConfigAssemblyNameMissingPKTAndCulture
public void GarbageAppConfigAssemblyNameMissingPKTAndCulture()
{
// Create the engine.
MockEngine engine = new MockEngine();
ITaskItem[] assemblyNames = new TaskItem[]
{
new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
};
// Construct the app.config.
string appConfigFile = WriteAppConfig
(
" <dependentAssembly>\n" +
" <assemblyIdentity name='GarbledOldVersion' />\n" +
" <bindingRedirect oldVersion='Garbled' newVersion='2.0.0.0' />\n" +
" </dependentAssembly>\n"
);
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblyNames;
t.SearchPaths = DefaultPaths;
t.AppConfigFile = appConfigFile;
bool succeeded = Execute(t);
Assert.False(succeeded);
Assert.Equal(1, engine.Errors);
// Cleanup.
File.Delete(appConfigFile);
}
示例15: RunTargetFrameworkFilteringTest
/// <summary>
/// helper for TargetFrameworkFiltering
/// </summary>
private int RunTargetFrameworkFilteringTest(string projectTargetFramework)
{
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = new MockEngine();
t.Assemblies = new ITaskItem[]
{
new TaskItem("A"),
new TaskItem("B"),
new TaskItem("C")
};
t.SearchPaths = new string[]
{
@"c:\MyLibraries"
};
t.Assemblies[1].SetMetadata("RequiredTargetFramework", "3.0");
t.Assemblies[2].SetMetadata("RequiredTargetFramework", "3.5");
t.TargetFrameworkVersion = projectTargetFramework;
Execute(t);
int set = 0;
foreach (ITaskItem item in t.ResolvedFiles)
{
int mask = 0;
if (item.ItemSpec.EndsWith(@"\A.dll"))
{
mask = 1;
}
else if (item.ItemSpec.EndsWith(@"\B.dll"))
{
mask = 2;
}
else if (item.ItemSpec.EndsWith(@"\C.dll"))
{
mask = 4;
}
Assert.NotEqual(0, mask); // "Unexpected assembly in resolved list."
Assert.Equal(0, (mask & set)); // "Assembly found twice in resolved list."
set = set | mask;
}
return set;
}