Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET CORE ALINK : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor

I am using VS2019 and .NET CORE 2.2 I am getting the warning AL1073

ALINK warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor

I know this is close to the question as: ALINK : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor

BUT:

  1. I am on .NET CORE 2.2 not on 4.x

  2. The solutions proposed there do not work on .NET core

in particular, attempting to add:

<PropertyGroup> 
<TargetFrameworkSDKToolsDirectory Condition=" '$(PlatformTarget)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)\$(PlatformTarget)\
</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>

gives another warning

Warning MSB3084 Task attempted to find "al.exe" in two locations. 1) Under the "\x64\" processor specific directory which is generated based on SdkToolsPath 2) The x86 specific directory under "\x64\" which is specified by the SDKToolsPath property. You may be able to solve the problem by doing one of the following: 1) Set the "SDKToolsPath" property to the location of the Microsoft Windows SDK. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets

Really strange, since the location is the same according to the warning!

Additionally: I would be happy to suppress the warning in the build settings, since all my unit tests pass, but adding 1073 to the list has no effect on the AL1073 warning which still appears.

Alternatively, the warning suggests: Set the "SDKToolsPath" property to the location of the Microsoft Windows SDK, how can I do that?

UPDATE to answer comment: This is hard to reproduce in a simple setup. the project references several Github projects (fo-dicom) in particular. The fo-dicom lib uses imaging libs built for 32 and 64 platforms. I did try setting to 64bits but it did not help. I saw other people raise the bug in VS community that the suppression of warning seems buggy: https://developercommunity.visualstudio.com/content/problem/224196/suppress-warnings-from-project-settings-build-does.html . That issue was closed without follow-up also MSFT stated that the AL 1073 will not be fixed, but I would like to disable! can't have warnings when using continuous integration...

I am now trying to recompile everything in .NET CORE 3.0, will provide an update if it works.

UPDATE: After recompiling in .NET CORE 3.0 I still have the issue.

I also found another cause of this issue (mentione in other SO articles, but for .NET 4.x. Indeed I saw that the issue came up also with resource files however with .NET Core we do not see the "Generating Satellite Assemblies" message so it is hard to link the compiler warning to the generation of the resource files.

In order to solve the issue I copied the al.exe file from C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64 into my solution into Tools64 and added the following to my .csproj

<PropertyGroup>
  <TargetFrameworkSDKToolsDirectory>..\Tools64</TargetFrameworkSDKToolsDirectory>
  </PropertyGroup>

Setting the SDKToolsDirectory directly to the original location did not work. Additional using the absolute path will not in my case where we use a devops build server for continuous integration (paths may be different). copying the al.exe tool locally seems to be an acceptable solution.

like image 401
shelbypereira Avatar asked Oct 25 '19 09:10

shelbypereira


2 Answers

The old workaround still works, but it has to be done before the GenerateSatelliteAssemblies target. When it is added as a PropertyGroup in the project file, it will be interpreted too late which results in the two locations warning.

As shown by Marcel Veldhuizen, it can be made to work by adding the following target:

<Target Name="FixAL1703Warning" BeforeTargets="GenerateSatelliteAssemblies" Condition="'$(PlatformTarget)' == 'x64'">
  <Message Text="Adjusting SDK tools directory to use x64 version of AL.EXE">
  <PropertyGroup>
    <TargetFrameworkSDKToolsDirectory>$(TargetFrameworkSDKToolsDirectory)$(PlatformTarget)\</TargetFrameworkSDKToolsDirectory>
  </PropertyGroup>
</Target>

Note: there is currently an open issue in the msbuild repository on GitHub about this.

like image 167
MightyJay Avatar answered Oct 25 '22 02:10

MightyJay


I was able to solve the issue, it seems in my case that I needed 2 things:

  1. Suggestion from gofal3, I referenced .NET core fo-dicom package and fo-dicom dependencies (but not fo-dicom desktop).

  2. It seems I had an old reference to Microsoft.ServiceFabric, it seems that that reference requires 64bit else we get the warning (Azure Service Fabric 32 bit support)

Lance: I tried the suggestoins in the blog to remove the warning, but that didn't help in my case. note that from the warning I was getting the path was the same.

like image 34
shelbypereira Avatar answered Oct 25 '22 02:10

shelbypereira