Publish Web application to ZIP file from Visual Studio 2015 - visual-studio

I want to publish my Web application to a ZIP file. To date I have been doing this by publishing to the file system, then manually zipping the output.
Is there a way of creating the ZIP file directly from Visual Studio? I've tried publishing using the publish method "Web Deploy Package". This generates a ZIP file, but the ZIP file contains a folder hierarchy that looks something like:
Content\C_C\...\MySolutionFolder\MyWebApp\obj\Release\Package\PackageTmp\
that mimics the folder hierarchy on my development machine. I just want the actual web content, i.e. the content of the PackageTmp folder.
I don't understand why the ZIP file contains this folder hierarchy: it means that deployments created on two different development machines with different working folders for the same source-controlled Visual Studio solution will produce different packages.

Related

How can I exclude files from Visual Studio, but still deploy them upon publishing?

We are experiencing bad slowdowns in Visual Studio 2019 that appears partly due to a large folder of content (~12,000 files) that we have in our wwwroot folder. This content rarely changes, but it ends up getting searched when we do "Find in files...", etc. which we don't need, and ends up slowing down normal operations such as adding/renaming classes.
Is there any way to keep the content in source control, exclude it from Visual Studio, yet still have it get deployed when we publish?
I haven't been able to figure out if this is possibly editing the csproj file using the settings such as DefaultItemExcludes, or various options on the ItemGroup element.
Here is what we have done to (hopefully) resolve this issue for us:
Added the following line to our WebApp.csproj file within the PropertyGroup:
<ProjectGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);wwwroot\hugecontentfolder\**</DefaultItemExcludes>
</ProjectGroup>
The huge content folder stays where it is in source control, this simplifies things as we need those files there to be served locally for development
We updated our Azure DevOps pipelines with new tasks to copy the contents of that folder from source control into the build artifact staging directory
Updated the Dotnet Publish Azure Devops task to no longer zip it's output
Another new Azure DevOps task to Archive the build artifact staging directory (which now has the non-zipped dotnet publish output, as well as the huge content folder output in the correct location) into a zip file for publishing.

VSIX - include other application in package

How can we include a separate .NET application inside a VSIX package? Preferably in a subdirectory so that it doesn't interfere with DLLs of the Visual Studio extension itself (different versions). The application is available in the same solution, but for the same reason I van also not add a reference to it in the main project.
The intention is to run that application as a separate process, started by the extension. The extension will then connect to that application through WCF.
I'm pretty certain you just need to include the .EXE in your .VSIX. A .VSIX is just a .zip file, and you can include additional files into it by simply adding them to your project and setting the Include in VSIX property to true.
To confirm, try downloading something like the Azure Data Lake and Stream Analytics Tools VSIX to disk. (I mention this one because I noticed it installed a number of .EXE's under my C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions directory).
Once you have the .VSIX on disk, rename it as a .zip file and unzip, or view its contents with the windows explorer. Note that the extensions.vsixmanifest file contained in that .zip has no references or entries for any of the .exe files installed by that .VSIX. Which means, all you really need to do is include it in the .zip file.
Add a subfolder to your .VSIX project, copy the .exe there, add it to your project, set the Include In VISX property to true, and I suspect you'll be all set.
Sincerely,

Visual Studio: How to automatically copy custom file to output directory only when publish website?

I got some files necessary for the hosting environment, e.g: robots.txt as in the attached image.
But I don't want to store them in Visual Studio solution, because they are not a part of my project, it will be confusing to have these under the solution folder or source control.
So, I am thinking is there anyway to let Visual Studio automatically copy these files from my custom location (e.g: D:\HostingPrepareForST\ ) to the output folder when I hit "Publish" to publish the website?

Problems Building a WCF Project with TFS 2010

I have a WCF project with a single .svc file and some .config files in it. I'm trying to create a build definition in TFS 2010 that will copy these files to an IIS folder on another machine.
I've done similar things with other MVC projects using the CopyDirectory task in the build XAML template. In those, I copy from the _PublishedWebsites folder to the IIS folder. However, with the WCF project, there is no _PublishedWebsites folder.
So I tried updating the MSBuild script for the WCF project to create a _PublishedWebsites folder and copy the files to it. This works when I build locally in Visual Studio 2010. But when it runs on the TFS build server, it doesn't quite work.
What I see there is that in "C:\Builds\1\PROJECT\PROJECT (Continuous Build)\Sources\PROJECT\bin\_PublishedWebsites", I can see all the files.
I'm guessing this "1 folder" is a temporary folder used for building...? I'm not sure what it's used for. But when I look at the actual drop location for the build, in "C:\Builds\PROJECT (Continuous Build)\PROJECT_BUILDNUMBER\", I see nothing except log files. None of the files from the "1 folder" are there.
Note that this same solution also has a WiX project to create a deployment package. That seems to build fine, and shows up in the drop location with no issue.
"1 folder" is a temporary folder used for building
Yes. "1" is number of build agent(service that actually executes builds activities) on your build machine.
But when I look at the actual drop location for the build, in "C:\Builds\PROJECT (Continuous Build)\PROJECT_BUILDNUMBER\", I see nothing except log files.
- Usually "Copy Files To Drop Location" flag is responsible for that.

Add external files to XAP (deploy extra files to WP7)

using XNA 4.0's TileStorage.OpenStream() you can access files located in the application's binary folder, which are deployed with your application.
You can add files to visual studio project and set them to "copy to output directory", and then these get deployed to the phone, and can be viewed on your PC by looking at your "bin\windows phone\debug" folder
however, if you copy files directly to the "bin\windows phone\debug" folder, these are not deployed to your phone (FYI they get deployed to your Xbox if you are doing xbox development)
How can I deploy additional files to the phone, without adding them to visual studio? Basically I wish to use a postbuild script to get content from a file share, and deploy this + an index file (generated in postbuild) to the phone.
is there any tool, or easy solution for this problem?
A xap file is just a zip file with a different extension. So you can use the post-build event to edit the xap before deployment, using any command-line-aware zip extractor.
For instance, with 7zip:
"C:\Program Files (x86)\7-Zip\7z.exe" a -tzip $(ProjectDir)$(OutDir)Test.xap C:\FileToInject.png

Resources