public void NuPack(string path)
{
using(dynamic ps = Runspace.DefaultRunspace.Dynamic()) {
DynamicPowershellResult results = ps.InvokeExpression(@"nuget.exe pack ""{0}"" 2>&1".format(path));
bool lastIsBlank = false;
foreach(var r in results) {
string s = r.ToString();
if (string.IsNullOrWhiteSpace(s)) {
if (lastIsBlank) {
continue;
}
lastIsBlank = true;
} else {
if (s.IndexOf("Issue: Assembly outside lib folder") > -1) {
continue;
}
if(s.IndexOf("folder and hence it won't be added as reference when the package is installed into a project") > -1) {
continue;
}
if (s.IndexOf("Solution: Move it into the 'lib' folder if it should be referenced") > -1) {
continue;
}
if(s.IndexOf("issue(s) found with package") > -1) {
continue;
}
if (s.IndexOf("Successfully created package '") > -1) {
var scp = s.IndexOf('\'') + 1;
var pkg = s.Substring(scp, s.LastIndexOf('\'') - scp);
if (pkg.Length > 0) {
(_packages ?? (_packages = new List<string>())).Add(pkg);
}
}
lastIsBlank = false;
}
// Issue: Assembly outside lib folder.
// Description: The assembly 'build\native\bin\Win32\v110\Release\WinRT\casablanca110.winrt.dll' is not inside the 'lib' folder and hence it won't be added as reference when the package is installed into a project.
// Solution: Move it into the 'lib' folder if it should be referenced.
Event<Message>.Raise(" >", "{0}", s);
}
if (results.LastIsTerminatingError) {
throw new ClrPlusException("NuGet Pack Failed");
}
}
}