Archive for December 2009

Nant, Tf Unable to determine the workspace

I was using Nant to checkout files in a build script and got the error “Unable to determine the workspace” from Team Foundation Server repository. The trick is to reset the cache first, run this command
tf workspaces /s:http://yourserver.com:8080 /noprompt
from your Nant script before doing any checkouts etc, then it should work.

C# download web page

I’m sure you had the need sometime to download the content of a web page to be able to analyze it or work with the content. Here is a code snippet just for you, we will use simple http GET for the specified URL.

public static string getWebPage(string psUrl)
{
    WebResponse result = null;
    string sRet = string.Empty;

    try
    {
        WebRequest req = WebRequest.Create(psUrl);
        req.Method = “GET”;
        req.Timeout = 3 * 1000// 3 secs
        // Explicit no caching, usually this is the default
        req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);

        // Has to process the results if the responding service is spitting it out
        result = req.GetResponse();
        Stream ReceiveStream = result.GetResponseStream();
        Encoding encode = System.Text.Encoding.GetEncoding(“utf-8”);
        StreamReader sr = new StreamReader(ReceiveStream, encode);
        // in case the caller is interested
        sRet = sr.ReadToEnd();
    }
    finally
    {
        if (result != null) result.Close();
    }

    return sRet;
}

The solution was offline during its previous session and will remain offline

If your .Net solution gets disconnected from your Team Foundation Server you might get the following message once you load your solution in Visual Studio. “The solution was offline during its previous session and will remain offline.” in the Output window and your solution is kept offline. Which means your local changes are not picked up automatically and you will need to do manual checkouts and checkins into the repository for local files you have changed.

The trick is to manually reset the values in the registry, where else ?
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers\ ( Your TFS server name )

set the values
AutoReconnect = 0
Offline = 0

Next time you open up your solution you will be asked if you want to connect to your Team Foundation Server, yes please.

Update…
If that does not work, try this one