Excluding files from Project Template C# - c#

I'm creating a project template to make the development process here in the company smoother.
I've created the template and it works ok, I can create a new project based on the template.
The only issue is that some files are included in the new project that I don't want included for instance the .vstemplate file.
I've searched the web/here on how to do this, but I can't find the answer...
What am I missing?

Would excluding files from the template project achieve what you want? You can do that by right clicking on a file in the solution explorer and clicking Exclude From Project
Example:

Related

Taking sln file from other app

I worked on some C# app (wpf), I uploaded it as zip file to google drive for now that's the only copy of the project That I have.
The problem is that I forgot to upload the .sln file.
When I downloaded the app from google drive to my pc I took some other .sln from other app and it worked fine for now.
Is it ok? I mean it can cause any problems in the feature?
A solution is sort of like a container that holds all your projects together. So as long as you have a valid project file (.csproj) you can simply create your own solution file and add the project to it.
If you go to:
File > New > Project
you can open up New Project dialog box.
There, under:
Installed > Other Project Types > Visual Studio Solutions
you can create a blank solution.
Once you do that, then you can add your existing project to this new empty solution.
For that, go to your Solution Explorer, right click the solution and select Add > Existing Project and select your project.
I took some other .sln from another app and it worked fine for now:
Most of the time: If you have a single csproj file, all you have to do is double click on the csproj file to build it. Visual Studio will automatically create a solution for your single csproj.
Is it ok? I mean it can cause any problems in the feature?
I think the big issues will only come when you have more than one project in your solution.
For example, lets say you have a solution with Project A and Project B, and project B has a reference to A.
You will need to add both projects to your new solution so that .NET knows to build A first, then build B using the output from building A.

Visual Studio Project rearrange project into folder with same name

Project name is testProject. I want to create a new folder named "TestProject" and move the project into it, because I want to add testProject.uTest and testProject.iTest for unit and integration tests. So everything related is located in the same folder.
The solution is in VSTS. Already one folder exists with the same name because of the project. Namespaces will all change.
How do I go about this the best way?
I got everything to work.
First I opened the solution and deleted the project in there. Then I created the new folder in the solution explorer. I then copied all the project related files into the new folder in windows explorer. I opened up the solution and added this existing project and add all files to source contrl. Next I had to re-add nuget packages and fix some references in other projects. Next I pushed the changes and then I deleted the old project files in source control explorer.
Took 10mins and everything works fine!
A few simple steps that worked for me:
Create a folder and add some text/number at the end:
Example: Infrastructure1
Create/Add the Project to your solution without the text/number at the end.
Example: Infrastructure
Rename the folder (Infrastructure1) to match your Project name(Infrastructure).
That's it, and you will get rid of the message that Project can't be named with the same name as the folder.

Open a csproj and not the entire solution

I am working on a solution that contains 30 cs projects. I am focusing on only 1 project so I preferred to open only this specific project.
Once opening this specific project, it loads the entire solution wiht all the others 29 projects.
Is there a way to open only this specific csproj?
The following structure can be used to get the desired behaviour:
Create a new Visual Studio solution
Delete the created default project
Add an existing project to the solution
Set the project as startup project (for re-build etc...)
You are now ready to go
You can do this in minutes and it's quite simple. Each sln file contains a number of projects that are written in this form :
Project(...) = "name.of.the.project", "{unique identifier of the project}"
and below that are the configurations for that project.
So you can write a javascript file to copy your original sln into each project folder found in that sln. After that iterate through each project folder and for each sln remove other projects. The javascript file can be runned using a .bat or cmd.
In this way you can assure that each project of your solution has inside his folder a new solution that contains that project.
We have a solution at work which has hundreds of projects.
So what we have done is have a Main.sln which contains everything. Then were have broken up the rest of the projects into different smaller solutions where they are grouped by relevance.
ie. All the database projects are in one solution, UI projects in another etc.

Where is the newly created build definition file?

In Visual Studio 2013,
Team Explorer,
I created a new build definition called Release. Now I want to edit the XML build file associated with this file so I click on "Edit Build Definition..." which shows me to the editing form for this build but not the XML file. Where is this proj file located. The project is already on TFS. Should I Check-in something which I am not aware of to be able to edit the xml content? Can't find this build?
The default build templates in TFS are WF XAML files and are only the templates for the build process. There is no XML file there for you to edit, the build details are stored within TFS.
Depending on what you are tying to do, you can look at editing or creating new Workflow templates, note that changes made to a template will effect all builds associated with the template.

Post build copy config file to another project

I have a solution which contains a website and various class libraries. The exists on the file system like so:
C:\Projects \MyWebsite\dev\MyWebsite.sln
C:\Projects\Core\MyClassLibrary1.csproj
C:\Projects\Core\MyClassLibrary2.csproj
I want to move the App.config file from MyClassLibrary1 project to the bin of the MyClassLibrary2. I want to do this on post build in VS or MSBuild using relative paths if possible. This way anybody checking out the projects will not have to modify any paths if they choose to locate the project in a different location.
I have already tried the following approaches but to no avail.
copy /Y "$(ProjectDir)App.config"
$(ProjectDir)\..\ MyClassLibrary2\$(OutDir)\ MyClassLibrary2.dll.config"
Any ideas?
Thanks
Consider adding the App.config file in your second class library using Visual Studio Add As Link.
Add -> Existing Item -> Add As Link
The Add As Link command is shown if you click the dropdown next to regular Add button in Visual Studio. This way you can reuse the file in multiple projects.
Try some other common MSBuild properties, although João has a better suggestion I think.

Categories