Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/wiki/ResolveAssemblyReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ By default, there are ten locations RAR will search (four if using the .NET SDK)

## There was a conflict

A common situation is MSBuild gives a warning about different versions of the same assembly being used by different references. The solution often involves adding a binding redirect to the app.config file.
A common situation is MSBuild gives a warning about different versions of the same assembly being used by different references. The solution often involves adding a binding redirect to the app.config file.

A useful way to investigate these conflicts is to search in MSBuild Structured Log Viewer for "There was a conflict". It will show you detailed information about which references needed which versions of the assembly in question.
2 changes: 1 addition & 1 deletion src/Shared/FileSystem/IFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Build.Shared.FileSystem
* Any new code should depend on MSBuildFileSystemBase instead of IFileSystem, if possible.
*
* MSBuild uses IFileSystem internally and adapts MSBuildFileSystemBase instances received from the outside to IFileSystem.
* Ideally there should be only one, public interface. However, such an interface would need to be put into the
* Ideally there should be only one, public interface. However, such an interface would need to be put into the
* Microsoft.Build.Framework assembly, but that assembly cannot take new types because it breaks some old version of Nuget.exe.
* IFileSystem cannot be deleted for the same reason.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,7 @@ public void ParentAssemblyResolvedFromAForGac()
Assert.Single(parentReferenceFolders);
Assert.Equal(reference2.ResolvedSearchPath, parentReferenceFolders[0]);
}

/// <summary>
/// Generate a fake reference which has been resolved from the gac. We will use it to verify the creation of the exclusion list.
/// </summary>
Expand Down Expand Up @@ -3652,7 +3652,7 @@ public void ConflictBetweenCopyLocalDependenciesRegress444809UnResolvedPrimaryRe
/// References - D, version 1
///
/// Both D1 and D2 are CopyLocal. This is a warning because D1 is a lower version
/// than both D2 so that can't unify. These means that eventually when
/// than both D2 so that can't unify. These means that eventually when
/// they're copied to the output directory they'll conflict.
/// </summary>
[Fact]
Expand Down Expand Up @@ -5982,7 +5982,7 @@ public void RedistListNoAssembliesinRedistList()
[Fact]
public void RedistListGenerateBlackListGoodListsSubsetIsSubsetOfRedist()
{
string redistFile = CreateGenericRedistList();
string redistFile = CreateGenericRedistList();
string goodSubsetFile = FileUtilities.GetTemporaryFile();
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/Tasks.UnitTests/AssemblyDependency/Perf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void DependeeDirectoryIsProbedForDependency()
bool succeeded = Execute(t);

Assert.True(succeeded);

uniqueFileExists[s_dependsOnNuGet_NWinMdPath].ShouldBe(1);
uniqueFileExists[s_dependsOnNuGet_NDllPath].ShouldBe(1);
uniqueFileExists[s_dependsOnNuGet_NExePath].ShouldBe(1);
Expand Down Expand Up @@ -109,7 +109,7 @@ public void DependeeDirectoryShouldNotBeProbedForDependencyWhenDependencyResolve
new Dictionary<string, string>
{
{"ExternallyResolved", "true"}
})
})
};

ResolveAssemblyReference t = new ResolveAssemblyReference();
Expand Down
22 changes: 11 additions & 11 deletions src/Tasks/AssemblyDependency/Reference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ sealed internal class Reference
private bool _isManagedWinMDFile;

/// <summary>
/// The imageruntime version for this reference.
/// The imageruntime version for this reference.
/// </summary>
private string _imageRuntimeVersion;

Expand Down Expand Up @@ -358,7 +358,7 @@ internal bool ResolvedFromGac

/// <summary>
/// Determines if a given reference or its parent primary references have specific version metadata set to true.
/// If anyParentHasMetadata is set to true then we will return true if any parent primary reference has the specific version metadata set to true,
/// If anyParentHasMetadata is set to true then we will return true if any parent primary reference has the specific version metadata set to true,
/// if the value is false we will return true ONLY if all parent primary references have the metadata set to true.
/// </summary>
internal bool CheckForSpecificVersionMetadataOnParentsReference(bool anyParentHasMetadata)
Expand All @@ -373,7 +373,7 @@ internal bool CheckForSpecificVersionMetadataOnParentsReference(bool anyParentHa
}
else
{
// Go through all of the primary items which lead to this dependency, if they all have specificVersion set to true then
// Go through all of the primary items which lead to this dependency, if they all have specificVersion set to true then
// hasSpecificVersionMetadata will be true. If any item has the metadata set to false or not set then the value will be false.
foreach (ITaskItem item in GetSourceItems())
{
Expand Down Expand Up @@ -589,7 +589,7 @@ internal string FullPathWithoutExtension
internal string AssemblyFolderKey { get; set; } = String.Empty;

/// <summary>
/// Whether this assembly came from the project. If 'false' then this reference was deduced
/// Whether this assembly came from the project. If 'false' then this reference was deduced
/// through the reference resolution process.
/// </summary>
/// <value>'true' if this reference is a primary assembly.</value>
Expand Down Expand Up @@ -629,7 +629,7 @@ internal ITaskItem PrimarySourceItem

/// <summary>
/// If 'true' then the path that this item points to is known to be a bad image.
/// This item shouldn't be passed to compilers and so forth.
/// This item shouldn't be passed to compilers and so forth.
/// </summary>
/// <value>'true' if this reference points to a bad image.</value>
internal bool IsBadImage { get; private set; } = false;
Expand Down Expand Up @@ -721,7 +721,7 @@ internal HashSet<AssemblyRemapping> RemappedAssemblyNames()
}

/// <summary>
/// Add a new version number for a version of this reference
/// Add a new version number for a version of this reference
/// </summary>
internal void AddPreUnificationVersion(String referencePath, Version version, UnificationReason reason)
{
Expand Down Expand Up @@ -819,7 +819,7 @@ internal void AddAssembliesConsideredAndRejected(List<ResolutionSearchLocation>
}

/// <summary>
/// Returns a collection of strings. Each string is the full path to an assembly that was
/// Returns a collection of strings. Each string is the full path to an assembly that was
/// considered for resolution but then rejected because it wasn't a complete match.
/// </summary>
internal List<ResolutionSearchLocation> AssembliesConsideredAndRejected { get; private set; } = new List<ResolutionSearchLocation>();
Expand All @@ -835,7 +835,7 @@ internal void AddAssembliesConsideredAndRejected(List<ResolutionSearchLocation>
internal FrameworkName FrameworkNameAttribute { get; set; }

/// <summary>
/// Indicates that the reference is primary and has ExternallyResolved=true metadata to denote that
/// Indicates that the reference is primary and has ExternallyResolved=true metadata to denote that
/// it was resolved by an external system (commonly from nuget). Such a system has already provided a
/// resolved closure as primary references and therefore we can skip the expensive closure walk.
/// </summary>
Expand All @@ -846,7 +846,7 @@ internal void AddAssembliesConsideredAndRejected(List<ResolutionSearchLocation>
///
/// For example, if 'sourceReference' is MyAssembly.dll then a dependent assembly file
/// might be en\MyAssembly.resources.dll
///
///
/// Assembly references do not have their own dependencies, therefore they are
/// </summary>
/// <param name="sourceReference">The source reference that this reference will be dependent on</param>
Expand All @@ -871,7 +871,7 @@ internal void MakeDependentAssemblyReference(Reference sourceReference)
}

/// <summary>
/// Make this reference a primary assembly reference.
/// Make this reference a primary assembly reference.
/// This is a refrence that is an assembly and is primary.
/// </summary>
/// <param name="sourceItem">The source item.</param>
Expand Down Expand Up @@ -1144,7 +1144,7 @@ public override string ToString()
}

/// <summary>
/// There are a number of properties which are set when we generate exclusion lists and it is useful to have this information on the references so that
/// There are a number of properties which are set when we generate exclusion lists and it is useful to have this information on the references so that
/// the correct reasons can be logged for these references being in the black list.
/// </summary>
internal class ExclusionListProperties
Expand Down
24 changes: 12 additions & 12 deletions src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ List<Exception> generalResolutionExceptions
{
/*
PERF NOTE: The Silent flag turns off logging completely from the task side. This means
we avoid the String.Formats that would normally occur even if the verbosity was set to
we avoid the String.Formats that would normally occur even if the verbosity was set to
quiet at the engine level.
*/
if (!Silent)
Expand Down Expand Up @@ -1119,7 +1119,7 @@ quiet at the engine level.
string details = string.Empty;
if (logWarning)
{
// This warning is logged regardless of AutoUnify since it means a conflict existed where the reference
// This warning is logged regardless of AutoUnify since it means a conflict existed where the reference
// chosen was not the conflict victor in a version comparison. In other words, the victor was older.
Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.FoundConflicts", assemblyName.Name, output);
}
Expand Down Expand Up @@ -1164,15 +1164,15 @@ quiet at the engine level.
{
foreach (AssemblyNameExtension conflictVictim in conflictVictims)
{
// Make note we only output a conflict suggestion if the reference has at
// least one conflict victim - that way we don't suggest redirects to
// Make note we only output a conflict suggestion if the reference has at
// least one conflict victim - that way we don't suggest redirects to
// assemblies that don't exist at runtime. For example, this avoids us suggesting
// a redirect from Foo 1.0.0.0 -> 2.0.0.0 in the following:
//
// Project -> Foo, 1.0.0.0
// Project -> Bar -> Foo, 2.0.0.0
//
// Above, Foo, 1.0.0.0 wins out and is copied to the output directory because
// Above, Foo, 1.0.0.0 wins out and is copied to the output directory because
// it is a primary reference.
foundAtLeastOneValidBindingRedirect = true;

Expand Down Expand Up @@ -2227,7 +2227,7 @@ ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader
if (targetingProfile)
{
// When targeting a profile we want the redist list to be the full framework redist list, since this is what should be used
// when unifying assemblies ect.
// when unifying assemblies ect.
AssemblyTableInfo[] fullRedistAssemblyTableInfo = null;
RedistList fullFrameworkRedistList = null;

Expand Down Expand Up @@ -2403,7 +2403,7 @@ ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader
dependencyTable.RemoveReferencesMarkedForExclusion(true /* Remove the reference and do not warn*/, subsetOrProfileName);
}

// Based on the closure, get a table of ideal remappings needed to
// Based on the closure, get a table of ideal remappings needed to
// produce zero conflicts.
dependencyTable.ResolveConflicts
(
Expand Down Expand Up @@ -2464,8 +2464,8 @@ out _copyLocalFiles
// If we're not finding dependencies, then don't suggest redirects (they're only about dependencies).
if (FindDependencies)
{
// Build the table of suggested redirects. If we're auto-unifying, we want to output all the
// assemblies that we auto-unified so that GenerateBindingRedirects can consume them,
// Build the table of suggested redirects. If we're auto-unifying, we want to output all the
// assemblies that we auto-unified so that GenerateBindingRedirects can consume them,
// not just the required ones for build to succeed
List<DependentAssembly> remappings = AutoUnify ? autoUnifiedRemappedAssemblies : idealAssemblyRemappings;
List<AssemblyNameReference> remappedReferences = AutoUnify ? autoUnifiedRemappedAssemblyReferences : idealAssemblyRemappingsIdentities;
Expand Down Expand Up @@ -2559,7 +2559,7 @@ out _copyLocalFiles
{
// Its pretty hard to get here, you need an assembly that contains a valid reference
// to a dependent assembly that, in turn, throws a FileLoadException during GetAssemblyName.
// Still it happened once, with an older version of the CLR.
// Still it happened once, with an older version of the CLR.

// ...falling through and relying on the targetAssemblyName==null behavior below...
}
Expand Down Expand Up @@ -2636,7 +2636,7 @@ private AssemblyNameExtension[] GetDependencies(Reference resolvedReference, Fil
{
try
{
// in case of P2P that have not build the reference can be resolved but file does not exist on disk.
// in case of P2P that have not build the reference can be resolved but file does not exist on disk.
if (fileExists(resolvedReference.FullPath))
{
FrameworkNameVersioning frameworkName;
Expand Down Expand Up @@ -2910,7 +2910,7 @@ private bool ShouldUseSubsetExclusionList()
return false;
}

// No subset names were passed in to search for in the targetframework directories and no installed subset tables were provided, we have nothing to use to
// No subset names were passed in to search for in the targetframework directories and no installed subset tables were provided, we have nothing to use to
// generate the exclusion list with, so do not continue.
if (_targetFrameworkSubsets.Length == 0 && _installedAssemblySubsetTables.Length == 0)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Tasks/Microsoft.CSharp.CrossTargeting.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project>

<!-- Import design time targets for Roslyn Project System. These are only available if Visual Studio is installed. -->
Expand All @@ -22,4 +21,4 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Import Project="Microsoft.Common.CrossTargeting.targets" />

</Project>
</Project>
5 changes: 2 additions & 3 deletions src/Tasks/Microsoft.CSharp.CurrentVersion.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
***********************************************************************************************
Microsoft.CSharp.CurrentVersion.targets

Expand All @@ -14,7 +14,6 @@ this file.
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project>

<PropertyGroup>
Expand Down Expand Up @@ -370,4 +369,4 @@ using System.Reflection%3b
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftCSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter')"/>
<Import Project="$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter\*" Condition="'$(ImportUserLocationsByWildcardAfterMicrosoftCSharpTargets)' == 'true' and exists('$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter')"/>

</Project>
</Project>
35 changes: 17 additions & 18 deletions src/Tasks/Microsoft.CSharp.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
***********************************************************************************************
Microsoft.CSharp.targets

Expand All @@ -14,26 +14,25 @@ this file.
Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project>

<Choose>
<When Condition="'$(IsCrossTargetingBuild)' == 'true'">
<PropertyGroup>
<CSharpTargetsPath>$(MSBuildToolsPath)\Microsoft.CSharp.CrossTargeting.targets</CSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<CSharpTargetsPath>$(MSBuildToolsPath)\Microsoft.CSharp.CurrentVersion.targets</CSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Choose>
<When Condition="'$(IsCrossTargetingBuild)' == 'true'">
<PropertyGroup>
<CSharpTargetsPath>$(MSBuildToolsPath)\Microsoft.CSharp.CrossTargeting.targets</CSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<CSharpTargetsPath>$(MSBuildToolsPath)\Microsoft.CSharp.CurrentVersion.targets</CSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>

<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.Before.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.Before.targets" />

<Import Project="$(CSharpTargetsPath)" />
<Import Project="$(CSharpTargetsPath)" />

<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.After.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.After.targets" />

</Project>
</Project>
Loading