In my C# project I'm referencing one of my company's DLLs, which is not on NuGet (as it's not public) and my pipeline in Azure DevOps keeps failing because it says it cannot find the reference.
Error CS0234: The type or namespace name 'YYY' does not exist in the namespace 'ZZZ' (are you missing an assembly reference?)
Following the advice from this post I have copied the dll in my solution and I'm referencing it from there, so the dll is version controlled and lives in the repo. Here an extract from the csproj:
<Reference Include="ZZZ.YYY, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\PrivateReferences\ZZZ.YYY.dll</HintPath>
<Private>False</Private>
</Reference>
The solution builds perfectly from my machine, but it keeps failing on Azure. What am I missing?
Thanks!
EDIT AFTER Bright Ran-MSFT REPLY
Here is the extract from my yaml:
trigger:
- develop
pool: 'Default'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: '<GUID of my Feed>'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
You can publish these DLLs as yourself custom NuGet package to an Azure Artifacts feed on Azure DevOps. Then in the pipeline for your project, you can use the NuGet restore task to restore the package into your project.
After publishing the package, when building your project via Visual Studio on your local machine, you also can connect to the Azure Artifacts feed to restore the package into your project.
[UPDATE]
Have you checked the output console logs of the pipeline run to see what caused the package can't be restored? Whether the reason is unauthorized error, such as 401
or 403
?
If so, before the NuGet restore task, you need to use the NuGet Authenticate task to provide the authentication information. Here you also need to create a NuGet service connection for use.
Normally, the feed you set up to publish yourself custom packages is private, when accessing the feed in the pipeline, the authentication is required.
On your local Visual Studio, due to you have log in with your account, VS will automatically authenticate with your account when you connect to the feed.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加