views:

410

answers:

3

I am working on creating a custom project template with Visual Studio 2008 Team System edition. I have also created a custom wizard for the custom template.

So I have to update the vstemplate file to tell the template to use my custom wizard. But the archive is corrupted!

7zip thinks folders within the archive are using non-standard zip compression. The latest winzip thinks the CRC header on the folders doesn't match the main CRC header.

What am I doing wrong?

If I don't change the template zip file created by VS2008, it works just fine. But I need to be able to update the zip file. If I do, 7zip/winzip fixes the zip file structure and then VS2008 doesn't like the template anymore. Files that are in folders within the zip file are inaccessible.

I do notice that the standard templates seem to keep a flat file structure. That is no nested folders or anything. But the vstemplate file has targetfilename attributes that recreate the original folder structure.

For example instead of...

<Folder Name="My Project" TargetFolderName="My Project">
    <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.vb">AssemblyInfo.vb</ProjectItem>
</Folder>

the standard vstemplate defines the following...

<ProjectItem ReplaceParameters="true" TargetFileName="My Project\AssemblyInfo.vb">AssemblyInfo.vb</ProjectItem>

I've just had a little think about the above. Are they actually the same thing?

Is the problem with the creation of the original zip file?

Is the folder structure within the zip file tripping everything up?

Should it have added all the files to the zip archive in as flat folder structure? If so is there a fix for VS2008 so that I do not have to manually fix the template archives?

A: 

Same problem here. I solved it by using <ProjectItem>MyFolder\MyFile.cs</ProjectItem> instead of <Folder>...<Folder>.

PS: TargetFileName doesn't work for me in VS2008 + Windows7.

penyaskito
A: 

It looks like Visual Studio creates non-standard ZIP files. My solution was to unzip the template zip file generated by VS, and then re-zip the files with WinZip.

You say VS2008 cant access all the files in the template when you do this, but here at least the resulting zip file didn't cause any problems for VS2008.

mackenir
Just to confirm, does your example zip have a nested folder structure or a flat folder structure?
BlackMael
Yep, I've just created a test project template with a project having a subfolder containing a cs file. the template's vstemplate file has <Folder> elements in the project template reflecting the directory structure. I unpack and recreate the ZIP using WinRAR (I have this installed at home).
mackenir
A: 

You don't need to modify the contents of the archive to be flat.

The trick is after editing the unzipped contents of the archive, instead of selecting the folder and zipping that, open the folder and select all the files (and folders if present), and zip those instead.

This is what is preventing Visual Studio from recognizing the archive as a template. This should work with 7-Zip, WinRAR, or whatever you happen to prefer to the bloatware that is WinZip.

David