Preventing TFS from adding Temporary files - c#

I am working on a Project that is bind in TFS, this project gives me a folder Log.
When I execute my project and do some testing it generates text files and store in Log folder.
After that when I try to check in files those files are checked in as a new file in TFS.
I want TFS to exclude these files. Folders where I store temp files are:
\WebPages\ErrorLogs
\WebPages\TempReports
Is there a setting in TFS where I can say it not to include this folder in TFS but Get latest from server if any?
Is it possible to create a Check-in-Policy for this problem?

Use the Forbidden Patterns Policy included in the TFS Power Tools
The following regex prevents suo files from being checked-in:
\.((?i)suo$)
The following regex prevents bin, obj and debug folders from being checked-in:
^\\(bin)|(obj)|(debug)\\$

If you are using Team Explorer Everywhere you can use this document to find out how to configure the policies directly through the Eclipse plugin.

Related

How to create folder in mvc solution directory so that it is included in project?

I am new in mvc and c# and I can't solve following problem:
I am trying to create a folder named "Items" in solution folder.
I have tryed to use CreateDirectory method:
Directory.CreateDirectory("~/Images");
But it didn't work for me - folder wasn't created ..
Partly working solution was to create a folder by :
Directory.CreateDirectory(Server.MapPath("~/Images"));
"Items" folder was created, but it is not included in the solution:
How to create folder in solution directory so that it is included in project ?
(I needs to by done by code not by hand)
You need to understand what solution and csproj file is used for
In general, they're being designed and used for development with Visual Studio, and once the project is compiled, all these files will be ignored and excluded from the deployment package
Directory.CreateDirectory(Server.MapPath("~/Images"));
The code above simply create the directory if not existed yet in the deployment package at run-time, so you won't see it in your solution unless you run the project locally (either debug/release mode, it does not matter here). However, everything will run normally in hosted environment (ex: IIS).
For your information, here's the brief of what solution and csproj is
solution (.sln) file: contains information to manage one or many individual projects, contains build environments (for each project), start up mode (useful when you want to start multiple projects in one run), project dependencies and so on. Take a note that VS also read from suo file (solution user options) which is used to defined user-custom preferences (you should not include the .suo file in the version control, because it's custom settings)
csproj file: define the structures of project, what the namespace is, what is static folders, embedded resources, references, packages, etc.
Lastly, if you create the folder manually, VS will auto include that folder into deployment package AND csproj, but depends on the file type, you might need to change the Build Action and Copy To Output Directory in file properties.
Hope it helps.
A deployed web application on a web server doesn't have any notion of Visual Studio solution or projects. So the Directory.CreateDirectory(Server.MapPath("~/Images")) is the correct way to create a folder inside your web application at runtime but we cannot be talking about including it into a solution because this hardly makes sense in a pre-compiled web application. If you create the directory on your local development machine, you could always manually include the folder to the corresponding .csproj file, but at runtime this will not make any difference whatsoever.
The reason I wanted to create a folder (if didn't exist) was to make sure it exits before I try to store image in it.
After reading posts here and a few google searches I have concluded that the proper way to handle image upload would be
To create (In my case) folder "Images" by hand to be sure it exists
Then storing uploaded img in existing folder:
string path =Server.MapPath("~/Images/"+ UploadedImageName);
file.SaveAs(path);

TFS update a project

I am a software developer working on a webshop. We are using nopCommerce 3.30 with custom plugins. The whole project is checked in on a TFS server. (Visual studio 2013, Team Foundation server 2012)
The problem is the following:
nopCommerce 3.40 was released, we downloaded the ZIP with the source code, but i am not sure how do i compare the diferences and check-in the new version. I can't just replace all files because i need to compare the folder structure / delete the files and folders that are not in 3.40 version.
Is there any compare function between 2 projects on either the client or server side ?
If you're using local workspaces, you can just delete all the code in your workspace, then copy the new code into the same workspace folder. Then examine the pending changes window. TFS will automatically detect all add/deletes/edits (you may have to promote some of the changes from the Excluded Changes section of the Pending Changes window).
extract the files to a local folder, you can then use the compare tool.
Map one side to the source location of the original package, map the other side to your local directory. this will show you differences in the folder structure, file names etc. you can repeat / drill down to do the same at the file level

Distributing open-source C# .NET code - what parts of the solution to check in?

I'd like to check in some C# .NET code to a new repository I've created on GitHub.
Usually we code in PHP/Python, in which case we'd just check in all of the .php or .py scripts and be done with it.
For my C# project, there's all of these extra files:
.sln
.csproj
obj/
bin/
To make this useful to other people, do I check all of those files in too? Or are these files specific to my computer, and shouldn't be in git/svn?
The gitignore file will usually be set up to ignore the obj/ and bin/ folders but you should upload the .sln which is the solution file and the .csproj which is the project file.
On github you can automatically create a .gitignore file based on the language you have coded in.
I think, yes, you should check-in *.sin and *.csproj files.
Pay attention that, these file are xml based files. when you add any other new item, you need to check-in these files too.
GitHub has reasonable .gitIgnore for .NET
key files I tend to ignore
# User-specific files
*.suo
*.user
*.sln.docstates
*.sln.cache
[Bb]in
[Oo]bj
localConnectionStrings.config
The localConnectionStrings.config is good for websites where you can set web.config like:
<connectionStrings configSource="localConnectionStrings.config" />
This stops everyone overwriting everyone else's local dev database connection string when they commit (if that's how you work).
If you are not committing the bin folder, setting Nuget Package Restore is useful too.

how do I reference a workspace directory in Visual Studio

I am using visual studio 2008 and I have a few files that I want to reference when in #debug mode. How do I get the directory of the workspace so that I do not have to manually change it every time I am at a different computer?
For instance, when I'm at work, my workspace is in c:\work2, when I'm at home, it is in d:\work.
This isn't an issue on the live product but it is when I change computers or other uses load the project since the files are in different directories for each workspace.
thanks!
Eroc
Add the test files (XML, spreadsheet, etc) as a 'Resource.' How to Add a Resource to your Project
Then, in your test files, you can use a relative address to access those files.
private const String = "./testFile1.xml";
You are able to have some pre-build command to change directory.

Which files should be checked in to SVN from Visual Studio Project Files in C#/VB?

I find this page very useful in distinguishing which files should be checked in to the Version Control System in Delphi. Is there a similar page that shows which files in VB.Net should be checked in to the repository?
I would recommend (from bitter experience) not checking in
SUO files (a users personal solution option files)
USER files ( a users personal project file settings)
The Bin folder and it's contents
The obj folder and its contents
Hope this helps
Put the solution file (.sln) into VCS.
Put all the files in the “My Project” folder into VCS.
From the main directory for your project:
Add the source code files. You will have explicitly created these files, with the extensions .vb, storing classes, forms and modules. In WinForms each form will have three corresponding files that must be added to VCS: “.designer.vb”, “.resx” and “.vb”.
You may also need to add other files with different extensions if you have created database connections etc.
Add the general files from the main project directory “app.config”, “ApplicationEvents.vb”, “Project.vbproj” and “Project.vbproj.user”.
In general don’t add any files from the obj or bin directory. These folders store built exes and intermediate files created by the compiler. You might want to keep the built EXE or DLL files in VCS, depending on personal preference.
By using Ankhsvn, I didn't have to worry on which files to be checked in because this tool knows it all.
Dean's answer is about as good as it gets. Most people make use of Visual SourceSafe or Visual Studio Team Foundation Server, which fully integrates with the Visual Studio environment and is able to automatically pick out the essential files.
But people who want to make use of some other VCS do ask, and sometime get a good answer:
http://www.codeproject.com/Messages/3645669/Files-in-a-VB-NET-project-to-put-under-Version-con.aspx
http://www.visualstudiodev.com/visual-basic-express-edition/which-files-directories-do-i-need-to-commit-to-version-control-cvs-71894.shtml
This one's about Visual SourceSafe (now regarded as obsolete):
http://msdn.microsoft.com/en-us/library/ms972977.aspx

Categories

Resources