We use TeamCity to build our projects when deploying to staging and production servers. Sometimes the Build Agent will get disconnected if the server gets restarted, and for some reason it won't reconnect.
If you are googling this issue frantically (like I have), you'll find a lot of people suggesting to open up Services in Windows and restarting the TeamCity Build Agent service. While this is needed, I found that doing so didn't reconnect the agent.
I finally started looking through the build agent configuration files, and found that the port change I had just done wasn't reflected in the build agent files. The file I was looking at was <TeamCity installation directory>\buildAgent\conf\buildAgent.properties and buildAgent.dist.properties. I had changed the port number for the web login, and while I saw in the buildAgent.dist.properties that it had the new port in the serverUrl config, the buildAgent.properties file still had the old port in the generated serverUrl.
I'm still not sure why the TC generation wasn't working, but I manually changed the port in the buildAgent.properties file. After restarting the TeamCity Build Agent service once more for good measure, I was able to see that the build agent was reconnected in the web interface.
Monday, April 10, 2017
Getting Grunt to run when deploying to a Windows server
I use Grunt to process my website css/js/etc files, which is quite handy. When deploying to a server, you do need to make sure that the files get processed as well. One way to do that is to install grunt on the server itself, and either run your grunt production task on deploy, or keep grunt running on the server with a watch task.
This is a short guide on how to run grunt as a Scheduled Task on a Windows server. (This assumes that you have already added a "watch" task on your grunt production task.)
This is a short guide on how to run grunt as a Scheduled Task on a Windows server. (This assumes that you have already added a "watch" task on your grunt production task.)
- Create a .bat file in the root website directory, with the only content being "grunt" or whichever grunt task you want to run.
- In Windows Server Manager, click on Configuration > Task Scheduler > Task Scheduler Library > Microsoft > Windows
- Click Create Basic Task
- Enter the name and description, click Next
- Select "When the computer stats" for when the task should start and click Next
- Under What action do you want the task to perform, select "Start a program" and click Next
- Under Action > Program/script type in the name of the .bat file (don't use Browse), and under Start in type in the full path to the website directory (if you don't do this and use Browse to path to the file it won't run). Click Next and Finish to finish creating have it auto open the properties.
- In the Properties pop-up dialog, under Security options, select "Run whether user is logged on or not" and "run with highest privileges"
Friday, April 7, 2017
Shuffle an array of items in Javascript
This function will take an array, shuffle the items, and return a shuffled array.function shuffleArray(array){
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
Wednesday, April 5, 2017
NuGet package errors in Visual Studio
If you're trying to install or manage NuGet packages in Visual Studio and you're getting error messages like "... end of Central Directory" or "Unable to read beyond the end of the stream," then you might have a corrupted .nupkg file.
To solve this, you will have to first see which packages are affected, and then manually download the .nupkg file for each package in question and replace them in your /packages directory.
To check which packages are corrupt, first open Visual Studio and the NuGet Package Manager in Tools > NuGet Package Manager > Manage NuGet Packages for Solutions.
Once you open it, click on the "Installed" tab and that is generally where you'll see the error messages.
To check which packages have corrupted files, open the /packages/packages.config file and one by one, comment out all but one of the <package> elements in <packages>, each time clicking back to the NuGet - Solution tab in VS to see if the error is still happening. If you don't get an error message for one, that means it's fine.
For the packages with errors, you will have to download the .nupkg files manually. Go to the NuGet site and type in the name of the package you want to download. Click "Download" in the left sidebar, making SURE that you have the same version that is in your Visual Studio! Then paste the file and overwrite your current corrupted .nupkg file in /packages/packagename.
Once you do this for each of the corrupted packages, uncomment everything in packages.config and check in the Installed tab again. Hopefully your error messages will be all gone and you'll just have a list of the installed packages.
To solve this, you will have to first see which packages are affected, and then manually download the .nupkg file for each package in question and replace them in your /packages directory.
To check which packages are corrupt, first open Visual Studio and the NuGet Package Manager in Tools > NuGet Package Manager > Manage NuGet Packages for Solutions.
Once you open it, click on the "Installed" tab and that is generally where you'll see the error messages.
To check which packages have corrupted files, open the /packages/packages.config file and one by one, comment out all but one of the <package> elements in <packages>, each time clicking back to the NuGet - Solution tab in VS to see if the error is still happening. If you don't get an error message for one, that means it's fine.
For the packages with errors, you will have to download the .nupkg files manually. Go to the NuGet site and type in the name of the package you want to download. Click "Download" in the left sidebar, making SURE that you have the same version that is in your Visual Studio! Then paste the file and overwrite your current corrupted .nupkg file in /packages/packagename.
Once you do this for each of the corrupted packages, uncomment everything in packages.config and check in the Installed tab again. Hopefully your error messages will be all gone and you'll just have a list of the installed packages.
Subscribe to:
Posts (Atom)