In a post build step we create nuget packages. For some reasons this always fails on my machine, while it works on other developers machines.
The command executed is:
nuget.exe pack "$(ProjectPath)" -Properties Configuration=$(ConfigurationName) -OutputDir "$(ProjectDir)..\Apps"
The output i get is:
Packing files from ''.
Using 'Organisation.AppName.Modules.Kcs.nuspec' for metadata.
The path is not of a legal form.
For other developers the first line contains the directory. What can be the reason it is working differently on my box? Are there options i can set to change this behavior?
Edit: I downloaded the nuget source and found the point things start to go wrong. With a small test program i can simulate it:
using System;
using Microsoft.Build.Evaluation;
namespace CheckTarget
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("usage: CheckTarget projectfile.csproj");
Console.WriteLine();
return;
}
string path = args[0];
var project = new Project(path);
Console.WriteLine("TargetDir = {0}", project.GetProperty("TargetDir") != null ? project.GetProperty("TargetDir").EvaluatedValue : string.Empty);
Console.WriteLine("TargetPath = {0}", project.GetProperty("TargetPath").EvaluatedValue);
Console.ReadKey();
}
}
}
On my machine the targetdir is null, on another machine the targetdir points to valid directory.
Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.
Install the official nuget.exe in your PC. Create a Symbolic Link here: %localappdata%\microsoft\winget\links. Make the nuget.exe globally available for your user to call it from anywhere, since the aforementioned directory should be present in your user's PATH variable.
Use property Platform to -Properties parameter in nuget program
-Properties Platform=$(Platform)
where $(Platform) is one of your project platform (defined in csproj file, typically x86, 'Any CPU', ..).
ie in your case, run something like:
nuget.exe pack "$(ProjectPath)" -Properties Configuration="$(ConfigurationName)" Platform="$(Platform)" -OutputDir "$(ProjectDir)..\Apps"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With