Build an executable file without Microsoft Visual Studio from project file - c#

I don't have MS Visual Studio installed and can't install it due to financial/legal reasons. I've inherited an executable file built with Visual Studio using C#. It isn't working as planned. I can fix the problem by changing 1 line of code. I have done so, but now I don't know how to re-build the project into an executable without Visual Studio.
I've tried running the following code from the command prompt:
>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe
/out:exchange.exe exchange.csproj
Am I on the right track?
Edit: This question is different from this question because here I ask about building and compiling a whole project... not just a .cs file.

I would suggest installing Visual Studio Community edition (free)
But, if you just want to build using msbuild through the commandline the simplest way would be (assuming you navigated to where msbuild is or have the env path set):
msbuild "C:\Users\Something\Documents\Visual Studio 2015\Blah path\Hello.csproj"
Building (then running) a simple console app that prints hello with the above:

You can use MonoDevelop for compiling your C# project.

Related

Compile C# Visual Studio 2019

Recently I downloaded the Visual Studio 2019 Preview. When I run a c# program a program called dotnet.exe runs instead . The problem is that in the old visual studio when you ran it would compile it and open the program that it just compiled. When I tried to use the old Visual Studio I had the same problem. I want a stand alone .exe compiled like how the old vs did. how do i do that?
The shortest answer is to create a .NET Framework project, not a .NET Core project. That will be the same as the projects you are familiar with.

Task could not be loaded from assembly

I have an error in one of my projects at work. The error says:
Severity Code Description Project File Line Suppression State
Error The "StyleCopTask" task could not be loaded from the assembly
C:\Projects\Project
Name\Source\\MSBuild\StyleCop\v4.7\StyleCop.dll. Could not load
file or assembly 'Microsoft.Build.Utilities.v3.5, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified. Confirm that
the declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class
that implements
Microsoft.Build.Framework.ITask. DskDirectMarketing.Common
Here I can clearly see that there is problem in the relative path which VS is looking for StyleCop. Here is how it looks like:
<Import Project="$(SolutionDir)\MSBuild\StyleCop\v4.7\StyleCop.targets" />
and my SolutionDir declaration looks like this:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
After some digging I noticed that in the error which prompts me there are 2 slashes:
C:\Projects\Project Name\Source\MSBuild\StyleCop\v4.7\StyleCop.dll
First thing I tried was to remove the dash from
<Import Project="$(SolutionDir)MSBuild\StyleCop\v4.7\StyleCop.targets" />
Id didn't worked.
After that I tried to put the absolute path but I had 2 slashes again.
How can I resolve this issue? Any help would be appreciated.
Based on #MaKCbIMKo's answer I installed .Net Framework 3.5 and this fixed my problem.
If you are using Windows 10, enable the .net framework 3.5 and if does not allow you to do so, open command prompt and run:
Dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess
If you're also using Visual Studio 2019 on Windows 10, you could try the following:
Close your Visual Studio instance.
Open Visual Studio Installer.
On the version of Visual Studio that you're currently using, click on More and select Modify.
Select the Individual components tab.
Search for .NET Framework 3.5 development tools, select it and click on Modify.
Wait for the modification to finish.
Open your project in Visual Studio, then do a Clean, followed by a Build.
In my case the paths were correct, but visual studio needed to run under elevated permissions to access the file in question.
We need to use visual studio installer to install the .netframework 3.5 , if the visual studio installer shows both options Visual Studio 2019 and Visual studio Build Tools 2017. follow below step
If you are using the Visual Studio 2019 ( mine was 16.11.3 but should work for all the versions). you will have Visual studio 2019 and Visual studio build tools 2017 .
Select the Visual Studio Build Tools 2017 => select modify => go to individual components => select .Net Framework 3.5 development tools
Then proceed with the installation.
-Ideally it should work once you re open the Visual studio , if not restart the system

Is it possible to work on a ASP.NET application on Visual Studio 2015 and VS Code? [duplicate]

How do I open I a Visual Studio Code folder in Visual Studio 2015?
If I open it as a "Web Site", it tries to treat the node_modules directory as part of the project's normal JavaScript files and hits an error when the path exceed the maximum path length.
But I can't open it as any other project type unless I first create a project of that type and then move all the VS Code files into that folder.
Should I be trying to open it as a web site?
Or should I create a new project and then copy the files + folders into it?
Is there any advantage to having it as a project?
If I do create a project, it makes it difficult to work together with someone who is just using VS Code?
And if I use a project, which project type should I select?
Finally folder view has arrived in VS 2017 :)
You can find more details in here.
Currently there is no way to open a folder directly with Visual Studio.
Why? Because Visual Studio and Visual Studio Code only shared their name, not the idea behind it. To extend Jenny O'Reilly answer:
Visual Studio Code is a folder oriented editor
This means VSC has the same Point-of-View to your Project as the File Explorer.
Visual Studio (not Code) is a solution oriented integrated development environment (short IDE)
Instead every Project in Visual Studio needs a *.sln Solution-File as Root Component. From this point Visual Studio looks at your Project. An example would, if you copy File in your Project Folder, they wouldn't be recognized from Visual Studio. You have to add them first to your sln File, to see them. It also allows the developer to combine multiple projects (*.csproj,..) into one single Solution to build.
This means the idea behind these two editors is completely different.
Visual Studio (not code) Project-types for Web
There are Node.js Tools for Visual Studio
This will provide Node.js built-in project templates
Visual Studio 2015 comes with TypeScript templates
Workaround 1
A workaround would be a Blank Solution in which you set up your Visual Studio Code Project.
Workaround 2
Another trick would be the answer to this question. You can open your Project Folder as a Website Project.
File -> Open Website -> File System and choose the folder
Update
As you mentioned, there will be errors because Visual Studio tries to build the solutions. For the next few readers of this response, the work around for this (as John Pankowicz writes in the comment) is:
Right-click Web Site in Solution Explorer -> Property Pages -> Build -> Uncheck "Build Web Site as part of solution"
Update 2
(Thanks to JC1001 for this update)
The next version of Visual Studio (Visual Studio "15") will support opening a folder. This is mentioned in the Visual Studio Blog.
Also like in Visual Studio Code, there will be a prompt command for opening Folders. Right now you can use this in the preview version:
devenv /command “file.openfolder FOLDER_PATH”
In the future you will be able to use:
devenv FOLDER_PATH
Opinion
Personally I wouldn't recommend Visual Studio (not code) for HTML/Website projects without server-side-development, because I don't see any features. Even the intellisense suggests to me sometimes bad HTML Code (it's not the IDE's fault).
After all web projects are still text files. You can easily control group projects like this with Version Control. Visual Studio Code even provides an integrated Git support.
Visual Studio Code does not create "project files" that you can open in Visual Studio 2015. Basically, when you open up a Node website in Visual Studio, you need to re-create the folder structure in VS2015 and create a "project file".
I haven't seen any better ways of doing this, but will be happy when we can open a folder just as easilly as we can with VSCode
I'm sure it's not the best way but..
Open an existing .sln with notepad, change the names, save as [name of your project].sln.
Open with Visual Studio.

Run a .cs file - visual studio 2012

Hi im starting to learn c# just now with visual studio 2012 and windows 8, and the tutorial has given some .cs files and not explained how to run them. It is all command line stuff in this tutorial. This stack overflow answer gave the most easy-sounding way of doing it (in response to a similar question by someone else).
If you already installed Visual Studio, just: Click Start, point to
All Programs, point to Microsoft Visual Studio, point to Visual Studio
Tools, and then click Visual Studio Command Prompt and there you have
your command line box where you compile as follows:
csc PathToYourCsSource
I cannot find visual studio tools. I typed it into the search in windows 8. Thanks
It is easier to: Run Visual studio -> Make a new C# console project.
This makes a project with a simple Program.cs file. You can just copy/paste in that, and run the project my clicking F5.
"Visual Studio Tools" is the name of the folder in the All Programs list, not the name of an item you can find by searching. You can search for "Developer Command Prompt for VS2012" (or some portion of that) instead.
I'd recommend that instead, you work with your .cs file as part of a project in Visual Studio. It's easy to create and run a Console Application from the IDE.
You can also use tools like Linqpad to run snippets of code so you don't have to use the bloat of an entire Visual Studio solution/project.
1.
in visual studio directory go to Common7>Tools>Shortcuts>Developer Command Prompt for VS2013 run this ,type csc programName.csc for compiling
and programName for run
Make sure to change the directory of console to your program path
2.
In visual studio create new C# console application and write there ,for run go to menu debug>Start Debugging

Building a .xap file from command line

Is it possible to build a .xap file from the command line like you would build a .cs file from csc.exe?
You can use MSBuild to build a project or a solution. From the Visual Studio Command Prompt, change your working directory to where your Solution / Project is:
>MSBuild YourSolution.sln
And now it is built. You do need the Windows Phone 7 Development tools installed on the machine for this to work.
You can also just invoke devenv from the visual studio command prompt that is installed as part of the SDK. MSDN has the relevant documentation.

Categories

Resources