I'm creating a VSIX project to read all the Config.xml files in the solution to generate many files within each project.
I'm having difficulty finding the Config.xml file inside a project and I believe it is because of the new Asp Net 5 project structure.
dte.Solution.Projects.Item(1) returns the "src" folder.
dte.Solution.Projects.Item(1).ProjectItems.Item(1).Name will return the project folder.
Then I cannot go any deeper inside the project because the item returned for the project is a ProjectItem and not a Project. ProjectItems do not have items.
How can I get a specific file in my project under asp net 5?
I am currently using a "Tools > Command" to execute the code. Would an project and/or xml file right click context menu fix this? If so how would I implement that?
Use the ProjectItem.SubProject property. See an example here:
HOWTO: Navigate the files of a solution from a Visual Studio .NET macro or add-in
Related
I followed the below steps,
Created a basic MVC application( say MVCTemplate) using predefined template in visual studio
Created a MVCTemplate.vsTemplate for above project using Export template wizard in visual studio
Added the newly created MVCTemplate.vsTemplate and a copy of MVCTemplate.csproj (Renamed to RequiredMVCTemplate.csproj) to the above project
Created a new VSIX project (MVCWizard) in the same solution
In MVCWizard project updated source.extension.vsixmanifest file by adding a new asset MVCTemplate (source = project , Type = Microsoft.visualstudio.Projecttemplate" and path)
Code is as below
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" d:Source="Project" d:ProjectName="MVCTemplate" d:TargetPath="|MVCTemplate;TemplateProjectOutputGroup|" Path="ProjectTemplates" d:VsixSubPath="ProjectTemplates" />
I get the below error
The target "TemplateProjectOutputGroup" does not exist in the project. Please suggest the best approcah to create a mvc project template and use it in wizard based vsix project and generate another such mvc application.
Four steps to follow,
Add the required files or folders in the project.
Update accordingly the csproj of the target project to be created.In this case its
RequiredMVCTemplate.csproj
Update vsTemplate file accordingly , using which the project will be generated.In this
case its MVCTemplate.vsTemplate
Rebuild the solution. This will ensure it creates a zip file which has the target
project template.
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.
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.
I had an Asp.Net MVC project, in VS 2013 update 4, and now I continue working on it in VS 2015. The Asp.Net version is not upgraded, i.e. I still use the stable asp.net 4 and MVC 5. The problem is: I cannot publish this project anymore. During the publish, it complains about xml files of every library I use, like EF, OWIN, ... both for Nuget libraries and normal .net framework libraries.
I tried adding these xml files from other sources and the publish proceeds further, but it raises another error like this:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(2991,5): Error : Copying file obj\Release\Package\PackageTmp\Content\bootstrap-rtl.min.css to obj\Release\Package\PackageTmp\obj\Release\Package\PackageTmp\Content\bootstrap-rtl.min.css failed. Could not find file 'obj\Release\Package\PackageTmp\Content\bootstrap-rtl.min.css'.
I removed this file from the project and the error still refers to this file. I searched the solution folder for this name, both in file names and file contents and I don't have it anywhere. It seems that Visual Studio has cached the publish procedure somewhere and does not update it when the project changes.
Any hints or solutions?
In our case the solution was to create a new clean project, then copy all source code files (C# code, javascript, css, razor templates, html, ..., but not for example, contents of bin and obj folders) from the old project into the new one, and then adding them to project (in solution explorer).
Don't waste too much time on solving this problem, dodge it.
I have a Silverlight 4 app that I'm building with Visual Studio 2010. I'm using Mercurial/TortoiseHG to do version control. Which files do I need to check in? By default, it checks in all sorts of .dlls in /bin/debug and stuff. Do I really need those? Or can I just grab code and content files? Do I need to version something to keep track of project properties and references, or is that contained within the .csproj file itself?
You don't need to include stuff in /bin or /obj. This is true of all VS solutions in source control. These are recreated upon every rebuild. Also, for Silverlight specifically, you don't need to check in the XAP file that is generated in the ClientBin of your web app.
From MSDN (via this social.msdn thread):
You can add the following files to Visual Studio source control:
Solution files (*.sln).
Project files, for example, *.csproj, *.vbproj files.
Application configuration files, based on XML, used to control run-time behavior of a Visual Studio project.
Files that you cannot add to source control include the following:
Solution user option files (*.suo).
Project user option files, for example, *.csproj.user, *.vbproj.user files.
Web information files, for example, *.csproj.webinfo, *.vbproj.webinfo, that control the virtual root location of a Web project.
Build output files, for example, *.dll and *.exe files.
It doesn't say anything specific about Silverlight projects though.
Is Mercurial/TortoiseHG integrated into Visual Studio? i.e. can you check out/submit from within VS?
If so, if you right click on the project name and select "Add Solution to Source Control" it should add those parts of the project that it needs ignoring everything else.