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:
![enter image description here](https://i.stack.imgur.com/LLwc8.png)
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:
![enter image description here](https://i.stack.imgur.com/rdtQY.png)
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.