I'm busy creating a Azure Devops build pipeline for a ASP.NET MVC application, but I'm stuck on restoring some NuGet packages.
I decided to add all folders to the .gitignore file that are added by NuGet package installs. Because pipelines will reproduce this files when doing a NuGet restore.
Unfortunately , for one of my installed NuGet-packages this doesn't work: the expected files were not added to my artifact.
When I install this package manually in Visual Studio, NuGet will add an assembly and some files inside the App_Plugins/uSync folder, but the NuGet restore step in Pipelines does not: it only added the assembly to the final artifact. The App_Plugins files are missing.
Below my YAML representation of the build pipeline:
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'artifact'
publishLocation: 'Container'
Any help much appreciated!
packages.config
, there is a difference betweenrestore
andinstall
. When youinstall
, it is allowed to modify the project, including copying files from the package into the project folder. Withrestore
, NuGet does not modify the project, it only downloads thenupkg
and extracts the zip in thepackages
folder.install
only works in Visual Studio, as NuGet asks Visual Studio's project systems to modify the project files (csproj
,vbproj
and so on). So, you need to check in those files as long as you keep usingpackages.config
. – zivkan<Reference
element that points to the assemblies in the solution packages folder. So, NuGet isn't restoring anything INTO your project, it's restoring only into the packages folder. The project is configured to consume those files from the packages folder. You can try yourself.git clean
to delete all yourbin
andpackages
folders. Do a NuGet restore locally. See there are still nobin
folders. – zivkan<Content Include="filename.ext" />
. NuGet doesn't know how to do that, but in VS when you install, NuGet tells VS to do it. – zivkan