I want to execute a msbuild script using a specific culture (en-US) as one of the tasks is trying to call a web service using aDateTime.ToShortDateString() as a parameter, and my current culture is uncompatible with the server's (english) format.
How to do it without altering my regional settings ?
I ended up by creating a specific task for changing the current culture like this:
public class ChangeCulture : Task
{
[Required]
public string Culture { get; set; }
public override bool Execute()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(Culture);
return true;
}
}
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