i authoring nuget package contain msbuild .targets , .props files per nuget documentation (requires nuget 2.5+).
i intend used automatic package restore.
when add resulting package csproj 2 things happen:
as expected:
<import project="..\packages\mypackage.1.0.0\build\net40\mypackage.props" condition="exists('..\packages\mypackage.1.0.0\build\net40\mypackage.props')" /> ... ... <import project="..\packages\mypackage.1.0.0\build\net40\mypackage.targets" condition="exists('..\packages\mypackage.1.0.0\build\net40\mypackage.targets')" />
not expected:
<propertygroup> <restorepackages>true</restorepackages> ... </propertygroup> ... <import project="$(solutiondir)\.nuget\nuget.targets" condition="exists('$(solutiondir)\.nuget\nuget.targets')" /> <target name="ensurenugetpackagebuildimports" beforetargets="prepareforbuild"> <propertygroup> <errortext>this project references nuget package(s) missing on computer. enable nuget package restore download them. more information, see http://go.microsoft.com/fwlink/?linkid=322105. missing file {0}.</errortext> </propertygroup> <error condition="!exists('$(solutiondir)\.nuget\nuget.targets')" text="$([system.string]::format('$(errortext)', '$(solutiondir)\.nuget\nuget.targets'))" /> ... </target>
that 'not expected' behaviour msbuild-integrated package restore scaffolding.
i have removed scaffolding manually per documentation when submit project build server automaitc-package-restore appears add scaffolding in, resulting in build failure.
this project references nuget package(s) missing on computer. enable nuget package restore download them. more information, see http://go.microsoft.com/fwlink/?linkid=322105. missing file d:\tfsbuilds\...\.nuget\nuget.targets.
does have way of blocking/preventing scaffolding being included when package includes msbuild targets?
update
in lieu of solution tried workaround. is, created nuget package address missing nuget.targets file. when added project, new package includes target dependsontargets ensurenugetpackagebuildimports , creates blank/valid nuget.targets. satisfies condition triggered csproj scaffolding, while allowing nuget automatic package restore function still triggered on build server.
<target name="nugetpackautomaticpackagerestoreprebuildworkaround" beforetargets="ensurenugetpackagebuildimports" condition="!exists('$(solutiondir)\.nuget\nuget.targets')"> <itemgroup> <patchtargets include="$(msbuildthisfiledirectory)targetpatches\*.targets"/> </itemgroup> <copy sourcefiles="@(patchtargets)" destinationfolder="$(solutiondir)\.nuget\"/> </target>
does folder solution lives in have .nuget
folder? if so, try deleting that.
i'm tweaking solution using old (pre nuget 2.7) way of package restore, , having same issue until deleted folder.