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.
Wednesday, April 5, 2017
NuGet package errors in Visual Studio
Tuesday, February 21, 2017
Adding field validation to Sitecore editor
Sometimes you may want to add validation to a field on Sitecore, like limiting the length of a text field. Sitecore comes with some sample field validations that you can add to your templates, or duplicate and modify to create new ones.
In the Sitecore Content Editor, go to sitecore > System > Settings > Validation Rules > Field Rules > Sample to see the pre-packaged rules. I wanted to create a Max Length 55 rule, so I duplicated one of the existing Max Length rules and changed the name, title, Description, and the Data Parameters to have that 55 value. Save and publish the rule.
Then go to Templates and expand the template until you can select the actual field in the left sidebar tree. In the right side, go down to the Validation Rules section, Validator Bar, and find the new rule you made in the Sample folder. Click to select, then click the ">" button to select it. Adding the rule to the validator bar will highlight the field in red if trying to save while the field is too long.
Save and publish the changes on the template, and you're done!
In the Sitecore Content Editor, go to sitecore > System > Settings > Validation Rules > Field Rules > Sample to see the pre-packaged rules. I wanted to create a Max Length 55 rule, so I duplicated one of the existing Max Length rules and changed the name, title, Description, and the Data Parameters to have that 55 value. Save and publish the rule.
Then go to Templates and expand the template until you can select the actual field in the left sidebar tree. In the right side, go down to the Validation Rules section, Validator Bar, and find the new rule you made in the Sample folder. Click to select, then click the ">" button to select it. Adding the rule to the validator bar will highlight the field in red if trying to save while the field is too long.
Save and publish the changes on the template, and you're done!
Monday, February 13, 2017
TeamCity Build Errors
A .NET site I work on uses TeamCity to deploy changes to both staging and live servers. I was encountering build errors related to the .csproj file on the staging server and couldn't figure out what the issue was. Looking at the build log, I noticed a bunch of errors saying "the type or namespace could not be found." However when I checked the files on the staging server, everything seemed to be there.
I was also googling about TeamCity and how it works (I inherited this project and am not super familiar with TC). I discovered that when TC builds, it actually copies all the files on the server into a separate TC work directory, builds that, then if it is successful it copies the changed files back into the actual server files. This means that the failed build was happening in the work directory, not the actual website.
The next day I went back to the problem with a fresh mindset. One thing I've started doing is the "talk to the duck" strategy for troubleshooting. This technique has you talk out loud to a rubber duck, or some other inanimate object, explaining what your issue is. This has actually helped me a ton when I'm stuck on some especially difficult problem. I don't talk out loud to an object, but what I have been doing is writing out the problem on a whiteboard. It works well because it takes you out of the tunnel vision when you're bug fixing and forces you to step back and look at the problem on a more high level.
Anyway, when I wrote out the problem, it was issues with the csproj file, and assembly errors. Knowing now that TC was erroring out in the work directory, I checked the bin folder and realized that it was almost completely empty. So I manually copied and pasted the bin files from the website directory to the TC directory and tried again. There were a couple other missing files which I also copied over. Finally I hit build one last time and it was successful!
I haven't done this yet, but I think the /bin and other missing files need to be added to the csproj. My guess is that the bin files were copied and pasted manually previously. But at some point TC probably ran a cleanup and deleted everything to build from scratch, meaning with an incomplete project file, thus causing all the build errors.
In summary, for TeamCity build errors, check the following:
I was also googling about TeamCity and how it works (I inherited this project and am not super familiar with TC). I discovered that when TC builds, it actually copies all the files on the server into a separate TC work directory, builds that, then if it is successful it copies the changed files back into the actual server files. This means that the failed build was happening in the work directory, not the actual website.
The next day I went back to the problem with a fresh mindset. One thing I've started doing is the "talk to the duck" strategy for troubleshooting. This technique has you talk out loud to a rubber duck, or some other inanimate object, explaining what your issue is. This has actually helped me a ton when I'm stuck on some especially difficult problem. I don't talk out loud to an object, but what I have been doing is writing out the problem on a whiteboard. It works well because it takes you out of the tunnel vision when you're bug fixing and forces you to step back and look at the problem on a more high level.
Anyway, when I wrote out the problem, it was issues with the csproj file, and assembly errors. Knowing now that TC was erroring out in the work directory, I checked the bin folder and realized that it was almost completely empty. So I manually copied and pasted the bin files from the website directory to the TC directory and tried again. There were a couple other missing files which I also copied over. Finally I hit build one last time and it was successful!
The green message box has never looked so good. |
I haven't done this yet, but I think the /bin and other missing files need to be added to the csproj. My guess is that the bin files were copied and pasted manually previously. But at some point TC probably ran a cleanup and deleted everything to build from scratch, meaning with an incomplete project file, thus causing all the build errors.
In summary, for TeamCity build errors, check the following:
- See where the errors are happening in the log file
- Check that the /bin files exist in the TC work directory
- Copy/paste any missing files to the work directory and add to the csproj
Thursday, February 9, 2017
Fixing Mixed Content Insecure Errors when Loading Telerik JS scripts via a CDN
Telerik gives you the option to load its scripts via a CDN. However, if your site is running on HTTPS, you will get a mixed content error and the scripts will be blocked.
As of the 2010 version of Telerik, it's possible to load the Telerik scripts securely over HTTPS. To do this, add CdnSettings elements inside your RadScriptManager, making sure to include one each for BaseUrl and BaseSecureUrl.
Further Reading:
The Telerik CDN – Now with SSL support too!
As of the 2010 version of Telerik, it's possible to load the Telerik scripts securely over HTTPS. To do this, add CdnSettings elements inside your RadScriptManager, making sure to include one each for BaseUrl and BaseSecureUrl.
<telerik:RadScriptManager runat="server" ID="ScriptManager1">
<CdnSettings BaseSecureUrl="https://d2i2wahzwrm1n5.cloudfront.net" TelerikCdn="Enabled" />
<CdnSettings BaseUrl="https://d2i2wahzwrm1n5.cloudfront.net" BaseSecureUrl="https://d2i2wahzwrm1n5.cloudfront.net" TelerikCdn="Enabled" />
</telerik:RadScriptManager>
Further Reading:
The Telerik CDN – Now with SSL support too!
Wednesday, February 8, 2017
Focus on a textbox using jQuery
You may want to auto focus on a textbox in cases like when you have a search textbox dropdown when clicking on a search button.
The jQuery method .focus() can help with this. However in order for it to work you may need to add in a small delay in order for the browser to pick it up.
The jQuery method .focus() can help with this. However in order for it to work you may need to add in a small delay in order for the browser to pick it up.
// Click event
$('#btnSearch').click(function(){
// focus on search bar after delay
setTimeout(function () {
$('#txtSearch').focus();
}, 500);
});
Friday, January 27, 2017
Real Favicon Generator
Here's a handy tool that will help quickly generate favicon, Apple, and Windows icons for your website. Just upload your originating PNG and it will create a zip file of all the files as well as give you an HTML snippet to put in your head tags.
http://realfavicongenerator.net/
http://realfavicongenerator.net/
Wednesday, December 7, 2016
YouTube Thumbnail Image URLs
120x90 (has black bars)
480x360 (has black bars)
320x180
640x480 (has black bars)
1920x1080
https://img.youtube.com/vi/YOUTUBEVIDEOID/default.jpg
480x360 (has black bars)
https://img.youtube.com/vi/YOUTUBEVIDEOID/hqdefault.jpg
320x180
https://img.youtube.com/vi/YOUTUBEVIDEOID/mqdefault.jpg
640x480 (has black bars)
https://img.youtube.com/vi/YOUTUBEVIDEOID/sddefault.jpg
1920x1080
https://img.youtube.com/vi/YOUTUBEVIDEOID/maxresdefault.jpg
Subscribe to:
Posts (Atom)