I solved this by setting the user account level environment variable, and depending on this, use it or use the default value.
I just changed the original PostBuildEvent and the surrounding PropertyGroup as follows:
<Choose> <When Condition=" $(NUGETLOCAL) != '' "> <PropertyGroup> <PostBuildEvent>if exist Diagnostic.nuspec if exist "$(SolutionDir)\packages\NuGet.CommandLine.2.8.2\tools\NuGet.exe" "$(SolutionDir)\packages\NuGet.CommandLine.2.8.2\tools\NuGet.exe" pack Diagnostic.nuspec -OutputDirectory $(NUGETLOCAL)</PostBuildEvent> <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> </PropertyGroup> </When> <Otherwise> <PropertyGroup> <PostBuildEvent>if exist Diagnostic.nuspec if exist "$(SolutionDir)\packages\NuGet.CommandLine.2.8.2\tools\NuGet.exe" "$(SolutionDir)\packages\NuGet.CommandLine.2.8.2\tools\NuGet.exe" pack Diagnostic.nuspec -OutputDirectory .</PostBuildEvent> <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> </PropertyGroup> </Otherwise> </Choose>
The environment variable is set to NUGETLOCAL with the value "C:\Users\jeroen\Google Drive\NugetLocal\VSDiagnostics" (including accents). If the variable is not set, it will use the default directory, and the user has the opportunity to define it anytime he wants.
The code is probably not as pretty as it may be, so let me know if you see an improvement.
I elaborated on this here .
source share