Write visual studio project from code - c#

Is there any way to write a Visual Studio Project file easy or do i have to look at the xml format and write it by hand?
Is there any lib for this in .net framework(3.5)?
Im using vb.net but c# would also work..

Visual Studio since version 2005 uses the MSBuild format to store C# and VB project files.
You could read this primer http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=472 or search the Web for further examples.
For programmatic access you could use the classes in the Microsoft.Build.BuildEngine namespace. Probably the Project class is of most interest to you.

I haven't tried this myself but you might want to look at http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.project.aspx

We do it from a couple of in-house tools. The project files for Visual Studio are stored as XML, so you can just use whatever XML classes you prefer. Make sure you pay attention to GUIDs as they are used to tie everything together between the various files in Visual Studio.

There is no support for this in the framework. The Visual Studio project file format is specific to Visual Studio. There may be support in the MSBuild libraries but you would need to include them as a reference and interact with it that way. What are you trying to do that requires you to create a VS project file?
The link provided here should give you what you need.

Related

How can Visual Studio Code on OSX import sln/csproj and run?

Visual Studio Code seems like it would be a very nice tool, but right out of the gate it seemingly cannot read any configuration that would make it part of the Visual Studio family. How can I import my sln/csproj files so that Code knows how to understand them?
Visual Studio Code isn't designed to work with sln/csproj files unfortunately (or fortunately depending on how you look at it).
In order to use your project created in Windows create a .NET Core application and use 'Portable Class Libraries' instead of standard class libraries then Open Folder in Visual Studio Code.
You can open it, using vscode-solution-explorer link for more info
(P.s. Not everything works as smoothly as we would like, but it's still better than nothing)

create a visual studio project and add files to it from a python program

I have a few questions:
Is there any way through which I could create a Visual Studio Project, add files to it, and build it from within a Python program?
Are there built-in commands to do this? If not any commands which could be run in command line?
Thanks for the help.
is there any way through which I could create a Visual Studio Project, add files to it
Whilst there is a .NET API for creating/manipulating project files, it's a bit on the undocumented side (I have used it in the past though) and I don't know if you can call it from Python. If you want to see the .NET API just look at the IronPython Custom Project Extension project.
However, VS project files are just XML files so if you know the schema, you can just write to the files from Python using your API of choice. VS won't know any better.
and build it from within the python program
Ultimately you can just spawn a process to invoke msbuild. Works for Jenkins.
Recently it looks like Microsoft has released Python tools for Visual Studio found here.
There is an Iron Python NuGet package that is tightly integrated with .NET, but not sure you'd want to use this for pure Python programming. I would also recommend Jetbrain's PyCharm which is an IDE also suited for Python or just use Notepad++ (free) and compile from the command line.

Automatically add NuGet dependencies and using statements in Visual Studio Code?

I am using Visual Studio Code to develop an ASP.NET 5 application on Mac. In order to use new classes (framework or third-party) in my .cs file, I need to
Manually add a NuGet dependency in project.json and then
Manually add a using statement to my .cs file.
It seems that there should be a better way to import new functionality that doesn't involve searching for the right NuGet and the correct namespace. Any suggestions?
Well, once I got my IntelliSense issues figured out (Visual Studio Code on Mac), I don't have to type using statements anymore. OmniSharp-based IntelliSense is smart enough to suggest (Cmd + . on Mac) adding them for me:
I still have to add a NuGet dependency manually, but I think this is the default behavior in the full Visual Studio too and you need ReSharper to get smarter than that.
Unfortunately, as far as I know of, the short answer is no.
Visual Studio Code is meant to be a light weight editor, so does not have support for the kind of feature you are describing out of the box. The full Visual Studio on Windows does have support for that. When you type the name of a class/type you want to use, eg. JsonConvert, it will detect that the missing type is available on NuGet and offer you the ability to download the correct package and add the using statement. (In the screenshot I already have the NuGet package installed, so it only needs to add the using statement)
This feature is available in the Community edition of Visual Studio, which you can download for free from the visualstudio.com website.
This does require you to run Windows, so I'm not sure if you consider this an option.
Now on the wishful thinking side: VS Code does support extensions these days and it has the power of the Roslyn engine, so theoretically someone could write an extension that will offer this functionality in the future.
You could also try getting it added to the core editor, by opening an issue on GitHub: https://github.com/Microsoft/vscode/issues
I'm afraid neither of these will really help you in the short term though.

Analog of Visual Studio Solution for my application

I would like to make an analog of Visual Studio Solution for my application.
I mean to make a file similar to Microsoft Visual Studio Solution file (.sln), which includes links to all the other solution files.
Can anyone link to an article on this topic? I could not find anything about it.
If you need to build a series of Visual Studio solutions, then you need a build tool.
The two most commonly used in the .NET world are
MSBuild (reference: http://msdn.microsoft.com/en-us/library/dd393574.aspx)
Nant (reference: http://nant.sourceforge.net/)
(It's not clear what you're asking, you may wish to clarify or give an example.)
I didn't really understand what you mean, but it seems that you need a building system, like CMake (www.cmake.org).

Can I work with Visual Studio Project and Solution files in a team using Subversion?

We're a team of students doing a software project. As some of us don't use Windows, but the product needs to run on Windows and .NET, we want to develop on MonoDevelop and Visual Studio which both use Visual Studio files; language of choice is C#.
My question is: Can we check in the solution and project files into our repository without the possibility of severe conflicting problems? Example: Two guys add a new file to the same project, save and commit their changes. Will the project file get a conflict?
SVN works great with Visual Studio and the related Project/Solutions files. The Project files are just XML and the Solution files are a structured text file. If changes are made to the same project/solution file from two different people the second person will get a conflict notice. Warning, it can be tricky to merge project and solution files. Sometimes it's easier to just toss the changes and add the files back manually then check in again.
You could try Agent SVN plugin. It integrates with VS 2005, VS 2008 and VS 2010 and it also has a import wizard feature that makes it easy to import the solution and all project files into the SVN repository.
I use this free Visual Studio plugin http://ankhsvn.open.collab.net/ for working with SVN repo ...
VisualSVN integrates well into VS.

Categories

Resources