I am trying to add some command line arguments to my application using CommandLineParser
:
using CommandLine;
using System;
namespace ConsoleApplication1
{
class Options
{
[Option('s', "site", Required = true,
HelpText = "The site to connect to. Please include http://")]
public string sitename { get; set; }
[Option('l', "list", Required = true,
HelpText = "The list to connect to.")]
public string listname { get; set; }
}
class Program
{
static void Main(string[] args)
{
var options = new Options();
Parser.Default.ParseArguments(args, options);
Console.WriteLine(options.sitename);
Console.WriteLine("\n");
Console.WriteLine(options.listname);
}
}
}
However, when I try calling this from CMD:
test -s sitename -l listname
I am getting this error:
Unhandled Exception: System.IO.FieNotFoundEsxcepion: Could not load file or assembly 'CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeytoken=de6f01bd326f8c32', or one of its dependancies. The system cannot find the file specified. at ConsoleApplication1.Program.Main(String[] args)
I have installed the CommandLineParser package and I can see it in my references list. When I navigate to this folder: \\file\IT\SK\Visual Studio Projects\ConsoleApplication1\packages\CommandLineParser.1.9.71\lib\net40
I can see that there is a CommanLine.dll
and a CommandLine.xml
.
Can someone please explain to me what is going on here?
Update
I am able to run this with command lines in Visual Studio if I DISABLE ClickOnce Security settings, and it works fine. However, when I publish the application, this is automatically selected and the problem persists.
When debugging with command line arguments and ClickOnce Security enabled, args[] is null ...