The majority of .NET core tutorials online seem to use Visual Studio code, rather than Visual Studio (Full fat? Is there a proper term for the full version? I use Professional but there is also Community, Enterprise etc).
These tutorials make the most of the integrated terminal within VS code for running dotnet command line commands (dotnet new, dotnet build etc).
I am struggling to find where to execute these commands in Visual Studio. Where is the right place to do this? I have .NET core SDK installed.
I have seen some suggestions for the package manager console - although this seems odd, why should I be running dotnet commands via a "package manager console"?
Update: Visual Studio 2019 16.6 now has it's own Terminal (Hoorray!). Check View -> Terminal or try to press Ctrl + `.
Old answer:
There are extensions for that. I tried BuiltinCmd and Whack Whack Terminal, the latter worked better for me. You can choose between CMD and PowerShell, all dotnet CLI commands works just fine.
The full version of Visual Studio is "Visual Studio", "Code" is what differentiates "Visual Studio Code".
As far as an integrated command line inside Visual Studio goes, the Package Manager Console is it. It's basically just powershell, with some addins from Visual Studio and any extensions or NuGet packages you have installed. It gets its name from the fact that it was introduced specifically for the management of NuGet packages, but was quickly co-opted by things like Entity Framework, and just continued to grow from there. Admittedly, Microsoft should probably consider rebranding it, but there's so much documentation, articles and tutorials out there that reference the "Package Manager Console", that it would probably actually create more confusion if they renamed it.
While you can run dotnet commands through it, I'd imagine the results would be a bit unpredictable. Perhaps I'm wrong here, as I've never even tried to do things like dotnet new from the PMC, but the PMC is not really directory-based like a traditional console window. It's more contextual in nature, applying commands to target projects. I do know that things like dotnet restore and such work fine, and dotnet new may as well. You'll just have to try it.
That said, I tend to take an all or nothing approach with Visual Studio. It's a beast, and if you're going to install it and use it, you might as well use it. You can do everything you can do with dotnet through the GUI. And, for those few times where you might need something special, you can pop a console window. If you want to do everything with dotnet, Visual Studio quickly becomes overkill, and Visual Studio Code would probably be much more efficient for your workflow.
While following a tutorial to update database, I had to run these commands
dotnet ef migrations add MaxLengthOnNames
dotnet ef database update
in the command window of Visual studio, as per tutorial. When I opened this window in visual studio (View > Other Windows > Command Window) and attempted to run these commands, I received this error:
>dotnet ef migrations add MaxLengthOnNames
Command "dotnet" is not valid.
>dotnet ef database update
Command "dotnet" is not valid.
>
When I attempted to run them in Package Manager Console, this is the result I got:
No project was found. Change the current working directory or use the --project option.
Now, I googled it a bit and got the hint that I must run these commands in windows command prompt (opened by typing "cmd" in Windows start search). Steps are:
Open windows command prompt
Set your project directory as current directory
run any dotnet command you need like I entered this: dotnet ef database update
success
I'm not sure what version of Visual Studio it was added, but Tools ... Command Line ... Developer Command Prompt will open a command prompt for you at your solution's root. From there, cd into the project you want to run and then dotnet run.
Also, if your version of Visual Studio doesn't have that menu option preinstalled, you can add it as an "External Tool" pretty easily: link
Tools -> Command Line -> Developer Powershell
You can execute cmdlets in the Visual Studio Package Manager Console that are functionally equivalent to at least some of the dotnet commands.
For example, there is a suite of cmdlets you can call that are equivalent to the dotnet ef commands. See here: https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
So the equivalent of dotnet ef migrations add MaxLengthOnNames in the Package Manager Console is Add-Migration MaxLengthOnNames.
And the equivalent of dotnet ef database update in the Package Manager Console is Update-Database.
Using that page I linked to it should be fairly easy to figure out the cmdlet equivalents of the remaining dotnet ef commands.
I don't know about dotnet run though.
Related
I need to open, edit, and debug an ASP.NET Core project in VS Code on a mac. The project was created in Visual Vtudio 2015 on a PC.
I'm having trouble. I get the error
No task runner configured
and it brings me to launch.json.
It sounds like a gulp thing and I'm not sure what I'd need gulp for... nor do I know what to do with launch.json, having come from visual studio 2015. Shouldn't it just launch in Kestral and go?
For some reason all the S/O questions and tutorials I've found through search are about creating a .Net Core project in VS Code and maybe opening it in Visual Studio... Not what I need. Other way around. Project created on PC in Visual Studio then open and fully develop on mac in VS Code.
Maybe my search query is wrong. Surely this isn't a new problem. Or, maybe I'm just doing something stupid.
When you click Launch. Then you select dot net core on launch json option. It would create a launch.json like this:
https://github.com/tuoitrevohoc/NetExpress/blob/master/.vscode/launch.json
Then you need to edit the path to your built dll file. And click run again. Follow the guide to create a task.json to build the project. Then when you click run again it will run.
I just download visual studio community to my pc. When i opened the vs-2015 and create new Console application project. i can't find it any where under the c# we installed templates or any templates.
Thinking about to uninstall and install again but this not the first time i uninstall and install this, i did installed and uninstall few time but still can't find the web Console Application template.
Thank you.
I had the same problem and found the solution on another site. Here are the steps that need to be performed:
Open a Visual Studio command window with admin privileges. This can be done from Windows search after clicking on the Windows button (or Start button - depending on the OS) located in the lower left corner. Make sure that you don't have any Visual Studio project open before proceeding.
Type in prompt in the search box and select "Developer Command Prompt". Right click on this and select run with admin privileges.
In the command window Enter:
cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
In the command window then enter:
devenv /installvstemplates
This worked for me and I was able to create a new console project after this.
With my version of VS 2015 community edition, upon install there was a Console Application (Package) template available, which I mistakenly thought was a Console Application template. This is not the case. It is a web console application project and I only discovered this after trying to access the File and Directory classes in System.IO from my code. The compiler kept on complaining:
Error CS0234 The type or namespace name 'Directory' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)
MyProject.DNX Core 5.0 ...
It still complained after putting in a reference to System.IO and even after changing the offending line of code to:
string DataPath = System.IO.Directory.GetCurrentDirectory();
A big clue here is the reference to DNX Core 5.0, which is an optimized run-time for ASP apps. It was at that point that I discovered that the Console Application (Package) template was also listed under the New Project window Templates / Visual C# / Web.
So, For others that may happen to find this post and think you are using a standard Console Application template, but have errors like "CS0234 The type or namespace "name" does not exist in the namespace..." then you could be using a Console Application (Package) template - which is probably not what you want and should be replaced by a regular Console Application. If you don't see it in the New Project window under Templates / Visual C#, then you should follow the steps above to install it.
EDIT
This is what my New Project window looks like after I performed the steps above:
Comparing this window with yours above, it appears to be somewhat different. Notice that "New Project" on my window is centered and for yours it is not. Also, at the bottom of the window yours has only Name, Location and Solution name, while my window adds a fourth item called Solution.
So, first thing, try clicking on Visual C# located in the left pane of your New Project window to see the templates available. Post that snapshot here. This can be done by selecting edit.
If you still don't see the Console Application template, then perhaps you downloaded a different version of Visual Studio 2015 than I did. So, here is the screen that pops up after selecting Help / About Microsoft Visual Studio on my system:
Compare this screen with yours and post a snapshot of your screen here. Also, what operating system are you using?
Thanks again Bob for your time to explained it to me, i am really appreciate that, I uninstalled and installed again from this link enter link description here, On my machine i have Visual Studio 2015(this one works) and Blend for Visual Studio 2015 is still missing template but i don't care it anymore if it work or not because i will use the one that works which is the Visual Studio 2015.
It happened that I cancelled an update when updating Visual Studio 2015 Community,
it cannot load the original solution I have had,
It gave such error:
Invalid entries passed to /FilterFeatureSelectionTree
then I searched on MSDN said to run:
VS2015.1 RC.exe /overridefeeduri
But it is said "Syntax incorrect in command"
Does anyone know how to run the above command successfully?
VS2015.1 RC.exe refers to the Visual Studio 2015 installer executable. So for example, if you saved the installer as C:\vs_community_ENU.exe and you want to use the English feed.xml, the command line would be:
C:\vs_community_ENU.exe /overridefeeduri "http://go.microsoft.com/fwlink/?LinkID=564093&clcid=0x409"
Note that the URL needs to be in quotes if executing from the command-line, otherwise the command-line interpreter might misinterpret the & in the URL and think that you're trying to issue multiple commands.
The best way to solve this is to download VS 2015 setup here: https://www.visualstudio.com/products/visual-studio-community-vs
then run the installer, choose "Modify" and select features you want install.
it did work for me as I wasn't able to install Python Tools from Visual Studio, but running the installer di solve the issue.
According log from failling installer, xml feed was alright, so previous answer cannot help.
Edit: I think the bug appears once you run the Web Platform installer, and if you cannot install it with VS installer, you should use Web Platform Installer instead
It looks like you need to know the path URI for the feed. MSDN says the syntax is
VS2015.1 RC.exe /overridefeeduri <Path to feed.xml>
You left off the last argument. The english feed URI is http://go.microsoft.com/fwlink/?LinkID=564093&clcid=0x409. The page you linked contains the URIs for other languages if needed.
I wasn't also able to install Python Tools from Visual Studio. Then I resolved this issue by trying multiple trial and error steps.
Trial 1:
I researched to find out the installer that installed the MSVS2015 in my Machine.As it was my office PC the installation was pushed out by the IT. The installer I found was at this directory
C:\ProgramData\Microsoft\VisualStudioSecondaryInstaller\14.0\installers\VS_SDKV1\en\0\vs****.exe
then I applied the following command
C:\ProgramData\Microsoft\VisualStudioSecondaryInstaller\14.0\installers\VS_SDKV1\en\0\vs****.exe /overridefeeduri feed.xml
After doing this My VS became unresponsive. I could not start it from the start menu.I thought I have by any chance damaged my Installation.Now I moved forward to step 2.
Trial 2:
go to Control Panel>Programs and features>select [Microsoft Visual studio 2015]>rightclick>[change]
On the screeen that appears on the window hit "Repair"
After the repair is complete. I repeated step a and this time I hit "modify" button. selected the "Python tools for Visual studio" and moved forward with "install/next" etc.
It worked out.I think only step 2 is good enough to set things right.I am not sure if Trial 1 did any good or not.
Thanks.
Another user has made several changes in different places throughout a specific project.
How do I see which files have been checked-in by a specific user?
From the command line issue:
tf history $/ProjectName /user:domain\user /recursive /noprompt
That will list all the changesets of that user
Then issue:
tf changeset 12345 /noprompt
To list all the changes in that changeset.
Currently I can't think of one command which will give you both. But you might be able to use Powershell or a custom console app that leverages the TFS Client Object Model to piece something together that does.
tf.exe can be found in the following folder: C:\Program Files (x86)\Microsoft Visual Studio {VISUAL STUDIO VERSION}\Common7\IDE. The easiest way to use it, is to open the command prompt using the "Visual Studio / Developer Command Prompt" item in the start menu that is created when you install Visual Studio.
As Tim Mentions, you can use the TFS Side Kicks to query this information as well. For Visual Studio 2010, this is still a stand alone application, for Visual Studio 2013 it nicely integrates into the Source Control Explorer context menu:
tfs sidekicks using the history sidekick will give you a GUI version of what the user's touched.
I have been using NuGet for quite some time on a particular PC. Now, I created a new project in VS2010 (it's an MVC 4 Beta project using the Single Page App template if that matters). When I select
Tools / Library Package Manager / Package Manager Console
The console window opens but displays the error:
File C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.7.30402.9028\Modules\NuGet\profile.ps1 cannot be loaded
because the execution of scripts is disabled on this system. Please
see "get-help about_signing" for more details.
However, other projects can still open and use Package Manager Console.
In each case, VS2010 is running as the same user.
If I open a command prompt (using the same account under which VS2010 is running), start PowerShell, and enter the command
Get-ExecutionPolicy
PowerShell returns
Restricted
My understanding based on a Scott Hanselman blog is that scripts should not run at all if the ExecutionPolicy is restricted.
Why are existing projects able to use the Package Manager Console while a new one is not?
Update: Changing the ExecutionPolicy to AllSigned and restarting VS2010 solves the immediate problem, but my main question is why the other projects were able to bypass the established ExecutionPolicy. VS2010 is not running as an administrator.
I experienced the same problem and solved it by:
Opening Powershell as an Administrator
Entering the following command "Set-ExecutionPolicy RemoteSigned"
Restart Visual Studio and the Package Manager Console worked as expected
It is important to note however that Powershell will give you a warning
"The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution policy?"
And should be careful of enabling this feature and should read more information in the help topics about the security risks.
In addition to Murries' answer, I found jellonek's post (on another thread) helpful. You might have to change the permissions on a different version of PowerShell (32-bit and 64-bit versions require separate permissions).
From How to Tell if PowerShell is 32-bit or 64-bit:
64-bit PowerShell Path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
32-bit PowerShell Path: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
Also, BOTH of these should work:
Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Unrestricted
Another way to fix this is by merging a Regedit file with the following content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
"ExecutionPolicy"="Unrestricted"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
"ExecutionPolicy"="Unrestricted"
(Create a text file called NuGetPowerShellFix.txt, copy paste the above into it, rename to NuGetPowerShellFix.reg, then run.)
After merging the above file, restart Visual Studio.
If you're using NuGet in Visual Studio 2013 and get this annoying error, go to Tools | NuGet Package Manager | Package Manager Settings and click "Clear Package Cache." Restart Visual Studio. I know there are multiple solutions to this, so this is yet another to try.
I have had this problem intermittently as well. I just came across it again and ran across this thread. In my latest case, I realized I had VS 2013 open twice (which normally is not an issue, I do it all the time). Since the only common theme of others that seemed to fix it was circumstantially related to requiring administrator privileges I gave it a shot and closed both instances of VS and reopened my solution in a new instance. Ran the nuget install and it worked without a hitch.
Based on this, I am thinking that it is a file permission issue causing this spurious error. Sort of like when windows has a lock on a file in the bin directory after a debug session and will not let you compile the solution.
You may be able to resolve this by not running Visual Studio as Administrator.
Different cause, same error message; might be helpful for someone who runs into this one.
Since we needed to create a project on a share on a remote server in our network and ran into similar problems here's what worked:
map the share as a network drive, say R: (but I guess it would also work without this mapping)
open Internet options > Security > Local intranet > Sites > Advanced (via IE or control panel)
add either "R:" or "file://server.domain.xy" (the former will automatically turn into the latter once you reopen the dialog)
run the x86 PowerShell executable and do "Set-ExecutionPolicy RemoteSigned"
Once I did all that Visual Studio didn't complain that the project was in an untrusted location upon opening the solution again, and it successfully ran all the PowerShell scripts for the packages that get auto-installed when creating a new MVC application.
I'm having this issue now, i think what worked for me easy was that i just had to restart visual studio 2013 and run it as administrator...worked fast for me.