Zipping Visual Studio Files

Anonymous
2022-06-02T19:19:56.07+00:00

I'm taking VB.NET Programming Essentials and I can't seem to get the files zipped correctly, which seems dumb because it's such a simple process. Every time I try accessing something that I zipped in the folder, it just shows that one of the files didn't load correctly and in the solution explorer section of visual studio, it just says that the solution hasn't been found.
I don't know if it's a settings issue or what but I've been trying to load everything and work with my professor for two full weeks on this and I am stressed beyond belief.
TIA!

Developer technologies | Windows Forms
Developer technologies | VB
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 60,326 Reputation points
    2022-06-02T20:56:07.73+00:00

    There is nothing special about Visual Studio in terms of zipping files. Do the following.

    1) In Visual Studio's Solution Explorer, right click the solution node and select 'Open in Folder Explorer' (or equivalent).
    2) You are now in Windows Explorer in the solution directory (e.g. you'll see mysolution.sln as a file). Step back 1 directory to the solution directory itself (e.g. mysolution).
    3) (Optional) Clean up unneeded files and folders including \bin, \obj, *.user.
    4) Right click the directory and zip it up.
    5) Send the zip file to the instructor and they can open it in Visual Studio.

    If you get a zip file and want to open it in Visual Studio you must first extract the files. Note that by default Windows will show you the zip file as a regular folder. This is wrong and attempting to open the solution within it using Visual Studio will fail (as will most programs) because it isn't actually a file on disk.

    1) Right click the zip file and select the option to extract the archive.
    2) (Optional) Specify the destination directory if your archive program supports it.
    3) You should now have the solution directory wherever you extracted the archive.
    4) Go into the solution directory and double click on the solution file (.sln). It will open in Visual Studio and everything should reload.


  2. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2022-06-03T12:00:37.713+00:00

    If this project is .NET Core 5 or higher, open the project file in solution explorer by double clicking the project node.

    Add the following

    <Target Name="ZipOutputPath" AfterTargets="Build">
     <Message Text="Creating .zip for $(SolutionDir)" Importance="High" />
     <ZipDirectory
     SourceDirectory="$(SolutionDir)"
     DestinationFile="C:\TODO\solution.zip"
     Overwrite ="true"/>
    </Target>
    

    Now in C:\TODO\solution.zip replace TODO with the folder name the zip file will be created and replace solution.zip with the name for your zip file. Make sure the folder to create the zip file exists first.

    To create the zip file clean and build the solution.

    Caveat, having the above in the project file will create the zip on each build so comment it out till ready e.g.

    <!--<Target Name="ZipOutputPath" AfterTargets="Build">
     <Message Text="Creating .zip for $(SolutionDir)" Importance="High" />
     <ZipDirectory
     SourceDirectory="$(SolutionDir)"
     DestinationFile="C:\TODO\solution.zip"
     Overwrite ="true"/>
    </Target>-->
    

    Edit To create a folder

    <Target Name="CreateDirectories">
        <MakeDir
            Directories="Place folder name here"/>
    </Target>
    

    This can be done with .NET Framework 4.8 but is more difficult.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.