2
votes

I've a .Net 4.7.6 solution with 400 projects. Some of those projects are referencing local DLL, some are using nugets packages.

Everything is building fine on our VS, everything is building fine on our build machine(with MSBuild), but once we pushed everything on Azure DevOps, we have a bunch of referenced DLL(not all) that doesn't load:

One example coming from package would be Log4Net:

##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5): Warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'log4net.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

(and obviously, it fails after because not finding it:)

##[error]Src\External\NModbus\Modbus\Device\ModbusMasterTcpConnection.cs(20,7): Error CS0246: The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)

Same errors for some locals DLL:

##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5): Warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'Unme.Common.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
 ##[error]Src\External\NModbus\Modbus\Data\DataStore.cs(16,7): Error CS0246: The type or namespace name 'Unme' could not be found (are you missing a using directive or an assembly reference?)

Not sure what I'm missing? What could be different regarding the loadable DLL between our VS Studio of the whole team and azure?

Here is our current build definition:

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: 'Solution/SomeSolution.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:

- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '>=5.4'
    checkLatest: true

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: Assembly-Info-NetFramework@2
  inputs:
    Path: '$(Build.SourcesDirectory)'
    FileNames: |
      **\AssemblyInfo.cs
    InsertAttributes: false
    FileEncoding: 'auto'
    WriteBOM: false
    VersionNumber: '5.1.0.*'
    FileVersionNumber: '5.1.0.*'
    LogLevel: 'verbose'
    FailOnWarning: false   
    
- task: MSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildVersion: latest
    msbuildArchitecture: x86
    platform: 'Any CPU'
    configuration: 'Debug'
    maximumCpuCount: true


- task: VSTest@2
  inputs:
    DisableTelemetry: false
    testSelector: 'testAssemblies'
    testAssemblyVer2: '$(solution)'
    searchFolder: '$(System.DefaultWorkingDirectory)'
    codeCoverageEnabled: true
    platform: 'Any CPU'
    configuration: 'Debug'
    rerunFailedTests: false

it makes one day that I'm stuck on this, quite frustrating :'(

1

1 Answers

3
votes

What could be different regarding the loadable DLL between our VS Studio of the whole team and azure?

When we deal with local dll files on Azure devops, we need to submit the those local dll files into the repo.

And the HintPath in the project file for those local dll files should be relative path not absolute path.

Last but not least, if you push dll files through git lfs to repo, in the Get Sources step there is a specific checkbox to enable git-lfs support. Without it the file will be replaced with a placeholder to the lfs download location:

enter image description here

Update:

we need to submit the those local dll files into the repo. what do you mean by that? All DLL are on our git(I mean, on a brand new computer with visual studio, I can checkout the code and build, no need to install anything else). Also, we use Azure Repository, so we don't have GUI steps, and I've no Get Sources step in the template that has been generated

I mean if we use those local dll files with Azure pipeline, we need submit those dll files with our projects to the Azure devops repo. When we create a build pipeline, we will select the build source, then Azure devops pipeline will checkout the build source to the build agent:

enter image description here

The code source could be Azure devops repo, Github, Github Enterprise server, Bitucket cloud. If you select the Azure devops repo as code source, we need submit and push those dll files to the Azure devops repo.

Next, when you open your build pipeline (YAML), and click the three vertical dots, select the Triggers and switch to YAML tab, you will see the get source:

enter image description here

enter image description here