Reputation: 1021
I'm trying to stop archiving into code source repository anything that comes from a Nuget package. For most, since they only have dlls, it works.
My problem is that I have one Nuget with a Content
folder in the nupkg. When building using VS2017, everything gets installed correctly but when doing the same thing using the build server (Azure DevOps Pipeline), I get
Error MSB3030: Could not copy the file "....." because it was not found.
The pipeline agent version is v.2.122.1 according to Capabilities. NuGet Task logs version 0.2.31 using NuGet 3.3.0.212 with MsBuild 14.0.
I see the nupkg files in the packages
folder but the Content
folder items don't get copied.
Is there anything special I need to add to my csproj or any additional steps I should add to my build definition?
Upvotes: 0
Views: 2086
Reputation: 76920
Is there anything special I need to add to my csproj or any additional steps I should add to my build definition?
You need change your csproj file to link the files from content package instead of add the files into the project. Since you are trying to stop archiving into code source repository anything that comes from a Nuget package, then add a nuget restore task to your build definition.
As test, I create a content package and add a copy event to copy file from the content package:
After installing that package, following content will be add to the project file .csproj
and packages.config
:
.csproj:
<ItemGroup>
<Content Include="resources\Test.txt" />
<Content Include="resources\Test2.txt" />
</ItemGroup>
Packages.config:
<packages>
<package id="TestContentPackage" version="1.0.0" targetFramework="net461" />
</packages>
Then we change the .csproj
file to link the files from content package:
<ItemGroup>
<Content Include="..\Packages\TestContentPackage.1.0.0\content\resources\Test.txt" />
<Content Include="..\Packages\TestContentPackage.1.0.0\content\resources\Test2.txt" />
</ItemGroup>
After change, the files from content package are not added to the project, just link to the project:
To verify the copy command, I add following copy command in the build event:
if not exist $(ProjectDir)TestFolder mkdir $(ProjectDir)TestFolder
xcopy /y "$(SolutionDir)Packages\TestContentPackage.1.0.0\content\resources\Test2.txt" "$(ProjectDir)TestFolder"
All the things work fine on my local.
Then I build this project with Azure devops, you need add the nuget restore task, otherwise, Visual Studio/MSBuild could not find the files from the packages. And it also work fine.
Note: If you want to copy the files from the content folder, you need copy it from the packages
folder.
Hope this helps.
Upvotes: 1