Exclude .svn from _bin_deployableAssemblies directory? - visual-studio-2010

In VS 2010 for ASP.NET MVC 3 project there is an option to add a "Deployable Dependencies" folder (_bin_deployableAssemblies) (click right button on web project), files contained in this directory will be copied to the /bin directory.
If you are using Subversion, this task will also try to copy .svn folder and its content, which will result in an error due to a collision with /bin 's own .svn folder.
Question: how do you exclude .svn folder from being copied to /bin?

Following seems to do the trick:
backup and open file Microsoft.WebApplication.targets (on my computer found in C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications)
find target named _CopyBinDeployableAssemblies
in that task find line:
.
<CreateItem
Include="$(MSBuildProjectDirectory)\_bin_deployableAssemblies\**\*.*"
Condition="Exists('$(MSBuildProjectDirectory)\_bin_deployableAssemblies')">
and add Exclude attribute as follows:
<CreateItem
Include="$(MSBuildProjectDirectory)\_bin_deployableAssemblies\**\*.*"
Condition="Exists('$(MSBuildProjectDirectory)\_bin_deployableAssemblies')"
Exclude="$(MSBuildProjectDirectory)\_bin_deployableAssemblies\**\.svn\**\*">

Related

Exclude folder and all sub folders and files in Visual Studio Web Deployment Project

In Visual Studio 2013, I am trying to exclude an entire folder from the MSI that is created. I tried to adding entries to the ExcludeFilter property of the "Content File from XXX (Active)" item but it doesn't appear to do anything.
I tried the following:
Exclude specific file: \Test\TimerWorker\1\Index.js
Exclude by wildcard: \Test\TimerWorker\1\*.*
Exclude by sub folder: \Test**\*.*
I also tried Googling for a solution and all I could find was about adding tags to the .csproj file but nothing has worked for me yet.
Edit 1:
I tried following the steps outlined in the following article but they made no difference. It looks like all I am able to do from the IDE is exclude files which are located directly under the root folder. Does anyone know how I can exclude an entire folder and all of its subfolders and files?
https://blogs.msdn.microsoft.com/webdev/2010/04/22/web-deployment-excluding-files-and-folders-via-the-web-applications-project-file/
First of all when adding files to installer project, you should add only primary output which will ensure to add only required dependencies.
:
Secondly, if any unwanted file show up in the installer project then you can simply right click and exclude, It will not be copied to destination.

How to "unignore" Visual Studio Web Site *.refresh files when you have [Bb]in/*

I'm using the standard Visual Studio .gitignore at
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
Part of that gitignore is to ignore the bin folders, but this is a problem, because I need to include bin/*.refresh files for visual studio web site projects.
When one has a (local file) web site project in: C:\Projects\MyprojectA\MyProjectWeb then any references to libraries are stored as "hint files" in the C:\Projects\MyprojectA\MyprojectWeb\bin folder as *.refresh.
So if you reference (a non framework DLL) AjaxControlToolkit.dll, so in the bin folder, you end up with AjaxControlToolkit.dll and AjaxControlToolkit.dll.refresh. The content of the file indicates the path of where to find that DLL. (Let's ignore the potential pathing problems when the repo is cloned, because we're checking in the DLLs into a _lib folder that's also checked into the repo)
How does one "unignore" the *.refresh files found within Visual Studio Web Site project bin folders so that they are included with clones of the repo?
How about using this VS feature?:
Use the exclamation mark.
**/[Bb]in/*
!**/[Bb]in/*.refresh
Once folders are excluded they can't be un-excluded. Do it this way to include sub-folders like roslyn.
replace
[Bb]in/
with
**/[Bb]in/**/*.*
!**/[Bb]in/**/*.refresh
Tiny expansion to Alex' answer, the 'Add Ignored File' button might be hidden under the 'Git' submenu.
'Add Ignored File to Source Control' button

Resource files in subdirectory are copied to root directory of the app bundle

I am not sure whether this is expected or it is bug.
I am trying to create the same folder structure in disk as that in XCode. I use the following steps to add resource files to my project:
Create a Resources folder under the root folder of the project.
Drag the Resources folder to XCode, which creates a Group for the folder.
Drag my resource files from Finder to the Resources folder in XCode.
And now I can see all the resource files are listed in Build Phrases->Copy Bundle Resources.
The weird thing is that [[NSBundle mainBundle] pathForResource:#"book" ofType:#"epub"] returns a file path that can be located, while [[NSBundle mainBundle] pathForResource:#"book" ofType:#"epub" inDirectory:#"Resources"] returns (null).
From the Build Results window, I notice this line:
CpResource MBookReader/Resources/book.epub /Users/neevek/Library/Developer/Xcode/DerivedData/workspace-fykuaikryknuhxgevcdtspkspptj/Build/Products/Debug-iphonesimulator/MBookReader.app/book.epub
cd /Users/neevek/workspace/xcode_projects/MBookReader
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip /Users/neevek/workspace/xcode_projects/MBookReader/MBookReader/Resources/book.epub /Users/neevek/Library/Developer/Xcode/DerivedData/workspace-fykuaikryknuhxgevcdtspkspptj/Build/Products/Debug-iphonesimulator/MBookReader.app
which shows that Resources/book.epub file is indeed copied to MBookReader.app/(the root directory of the app bundle).
Now Resources is a real folder in disk, why the folder itself is not copied?
PS. I am using XCode 4.3.2.
When adding your Resources folder to Xcode, choose "Create folder references" instead of "Create groups for any added folders" in the sliding window.
That is, replace the 3 steps in your question with the following ones.
Create a Resources directory under the root directory of the project. Organize your directory structure inside the Resources directory the way you want it to be.
Drag the Resources directory to XCode and select the Create folder references option.
You're done. Xcode will copy the contents of your Resources directory recursively into the bundle.
You might have trouble further down the road when Xcode doesn't copy a modified file somewhere inside the Resources directory. A clean build usually fixes this. Alternatively, you can remove the .app file before building. This will not cause unmodified source files to rebuild, but will force Xcode to copy all of the resources anew.

Visual Studio Test Project - Does not copy folder on deployment

Here is the problem:
1. Create a TestProject in your Visual Studio solution.
2. Open the .testrunconfig file and under the 'deployment' menu item, select the 'Enable Deployment' checkbox.
3. Now click on 'Add Directory...' button and add a folder which has some files in it.
4. Run the test project (use a dummy test).
Ok, now go check the TestResults folder: You will see that all the files got directly copied (to the top level)- the folder itself is not copied (with the files under them). This messes up my paths during testing. Can anybody tell how to get the folder copied instead of just the files underneath ?
Thanks.
Use the [DeploymentItem] attribute on the test classes that use it. You can specify a directory:
[TestClass]
[DeploymentItem("blahblah\\myDirectory", "myDirectory")]
public class MyTest
{
}
Note:
DeploymentItem is very slow when starting the tests. It seems to copy 2 files per second.
You can specify the attribute on a test base class. But it does not always work if you have more than one test project.
You can probably specify it on a TestClass that has a method marked with [AssemblyInitialize]. Then you have only to provide it once. Not sure, you have to try.
The source directory is relative to the solution location. This is hardly documented.
Open the .testsettings file in notepad. Now, you should see that for every folder to copy
<DeploymentItem filename="FolderName\" />
Change this to
<DeploymentItem filename="FolderName\" outputDirectory="FolderName\" />
The other option you have is to create another folder beneath the original folder, and then that folder will be deployed to the out directory. For example you can have this structure:
TestFolder/
TestFolder/TestDeployment/
And then in the testrunconfig you still select the TestFolder folder and the TestDeployment folder will be deployed to the out directory.
I just had this problem too today. I solved it by adding a folder called "deployment_files" in the project that contained the required folder. Then I put the required folder into the "deployment_files" folder. THEN, I opened the LocalTestRun.testrunconfig file under the "Solution Items" folder in the Solution Explorer. Went to the "Deployment" panel in the testrunconfig property window. Added the "deployment_files" directory to the deployment and voila. The folder within that was copied to the test results Out folder.

What's the easiest way to install 100s of files in a Visual Studio setup project

I have a standard c# application that acts as a GUI front end for a an "R" statistics engine. "R" consists of approx 600 files in approx 50 different folders and can be "installed" on a machine through xcopy deployment.
I would like to package up both the R engine and my c# gui into one setup.exe so that the user doesn't need to go and install R first and then my c# application seperately.
I know that I can produce a setup project and then add in the R files one by one but adding all 600 files will be very tedious!
Is there an easier way of doing what I want? Can I add the single R folder and automatically add the subfolders and files to save me adding them in one by one? Or maybe do an unzip procedure in my setup project which will unzip the R engine in one go?
You can simply drag/drop the folder in Windows Explorer into the File System view of your Installer vdproj. All the files and folders in the hierarchy will be added to your setup project.
Tip: If the folders are in SVN or similar source control, delete all the hidden folders before you do this! If you have PowerShell, check out
get-childitem . -include _svn -force -recurse | foreach ($_) {remove-item -recurse -force $_.fullname}
Or you can always use Windows Search to find all hidden directories in the hierarchy and delete them from the Results Window.
I couldn't work out the project file so what I did in the end was to zip up all the files I wanted to deploy, add the zip file to the application and create a custom Installer class to unzip them (using CSharp ziplib)
I think Badjer is most of the way there.
If your 600 files are part of a project and the "Build action" for each of these is set as content you can add all of these by simply:
Going to the setup project
Selecting Add > Project Output
Selecting the project the files belong to from the drop down
Selecting the "Content Files" option from the list below
Clicking OK.
You can check the files will be added to the appropriate place by going to View > File System on the setup project and checking that the content files output is being added to the correct folder.
The files will be added to the install directory in the same hierarchy as they are specified in the project they belong to.
Have a look at the project file. I believe is text based. You might be able to insert the file paths directly there with some copy-paste-replace.
One thing you could try is adding the R files as content in the C# project - then the setup project can just copy them over for you (make sure you configure the setup file to copy content files from your project, not just the primary output).
You can either add the R folders into the project manually, or set up a script to modify the .csproj file (it's just an XML file) - content items are represented by these nodes:
<Content Include="myfile" />

Resources