I am using VS Code on windows 10 and also code runner extension, everything was working fine till I used a workspace in a multi filed project, from there no file would to run through VS code automatically, I either have to use cmd or run it manually in the terminal.
I think the problem is that I used a workspace and it moved all my files to this workspace.
Now I can't even run any files that I created after this problem.
All the files names were changed to
file_name.py - Untitled (Workspace) - Visual Studio Code
Related
I have a strange issue that hopefully, someone can help me with. I got a new laptop and I'm trying to publish the same ASP.NET MVC 5 project on the new machine with precompiled views. However, when I do a publish with "Precompile during publishing" option checked, it does not create the precompiled views. Now, if I copy the exact command that it ran and run it in the Command Prompt, the precompiled views are created.
Here are the details. Both machines have Windows 10 Anniversary Update (Version 1607) with Visual Studio 2013 Update 5. Publishing the app on the old machine with the same publish profile generates the precompiled views. On the new machine, publishing from the "Publish Web" dialog runs without errors, but no precompiled views are generated. I then copied this exact command to the Command Prompt that VS used to precompile:
C:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p C:\MyApp\obj\Release\AspnetCompileMerge\Source -c C:\MyApp\obj\Release\AspnetCompileMerge\TempBuildDir
When I ran it, it created the precompiled views in the TempBuildDir\bin directory!
The only difference I can think of between the machines is the Windows Updates.
Any ideas? Thanks.
I ran into exactly the same problem.
It could be an issue with compressed folders (the drive is not compressed, but individual folders are). For some reason, the .compiled files are simply not generated.
This still applies to VS2019 and MVC5. (The latest toolchain as of today. Probably a .NET Framework issue, unrelated to VS and MsBuild versions).
This thread helped me find the solution (see the last answer):
https://social.msdn.microsoft.com/Forums/vstudio/en-US/cb6a4239-9765-4021-a7ab-e5ad3d8aef06/missing-compiled-files-when-publishing-an-aspnet-mvc-4-project-to-filesystem-on-tfs-build-server?forum=msbuild
Do you use the x64 verson of Windows?
Also you can try set $(AspnetCompilerPath) manually:
msbuild.exe /p:AspnetCompilerPath="C:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe"
or add it to your project:
<PropertyGroup>
<AspnetCompilerPath Condition=" '$(AspnetCompilerPath)'=='' " >C:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe</AspnetCompilerPath>
</PropertyGroup>
I've made this assumption, because the Microsoft.Web.Publishing.AspNetCompileMerge.targets file contains the string:
We can't use the in-place aspnet_compiler because it will output to the aspnet temp folder which is only suiteable to run on the current machine.
I've put Visual Studio Code on OneDrive, for the purpose of syncing it with its settings across my devices.
However, extensions are stored in %USERPROFILE%\.vscode\extensions on Windows.
Is it possible to change this folder's location so I can put it in the main Visual Studio Code folder?
At first I thought that copying the extensions in the resources\app\extensions of Visual Studio Code folder will be a nice workaround, but that doesn't work.
I've also searched for a solution on the documentation page and in the user settings, with no results.
What I did - after installing Visual Studio Code for the first time, I checked the documentation and added at the end of 'Target' field of editor's shortcut the following (there's a space before the two dashes):
--extensions-dir="DRIVELETTER:\VSCODE\extensions"
--user-data-dir="DRIVELETTER:\VSCODE\settings"
where DRIVERLETTER and VSCODE are the corresponding drive and directory where Visual Studio Code is installed. So mine looks like this:
"D:\Microsoft VS Code\Code.exe" --extensions-dir="D:\Microsoft VS Code\extensions"
Here is for the user data directory:
"D:\Microsoft VS Code\Code.exe" --user-data-dir="D:\Microsoft VS Code\settings"
Accessing the 'Target' field is done by right-clicking the shortcut and choosing 'Properties'
Anyway, there's a simpler solution to that problem - just use the portable version of Visual Studio Code. It works under Windows, Linux, and macOS:
Enable Portable Mode
Windows and Linux
After unzipping the Visual Studio Code download, simply create a data folder within Visual Studio Code's folder:
|- VSCode-win32-x64-1.25.0-insider
| |- Code.exe (or code executable)
| |- data
| |- ...
From then on, that folder will be used to contain all Visual Studio Code data, including session state, preferences, extensions, etc.
The data folder can be moved to other Visual Studio Code installations. This is useful for updating your portable Visual Studio Code version: simply move the data folder to a newer extracted version of Visual Studio Code.
macOS
On macOS, you need to place the data folder as a sibling of the application itself. Since the folder will be alongside the application, you need to name it specifically so that Code can find it. The default folder name is code-portable-data:
|- Visual Studio Code.app
|- code-portable-data
Portable mode won't work if your application is in quarantine, which happens by default if you just downloaded Visual Studio Code. Make sure you remove the quarantine attribute, if portable mode doesn't seem to work:
xattr -dr com.apple.quarantine Visual\ Studio\ Code.app
Note: On Insiders, the folder should be named code-insiders-portable-data.
UPDATE 14.12.2021
From Visual Studio Docs
Note: Do not attempt to configure portable mode on an installation from the Windows User or System installers. Portable mode is only supported on the Windows ZIP (.zip) archive. Note as well that the Windows ZIP archive does not support auto update.
A little hack:
Create a symbolic link to the folder %USERPROFILE%\.vscode\extensions under the Visual Studio Code install path.
https://code.visualstudio.com/docs/editor/extension-gallery
code --extensions-dir 'new_directory_to_set'
Set the root path for extensions.
Follow the below steps for changing the extension path in VS.
Set "code" path in environment variable.
path = VS_CODE_INSTALL_DIRECTORY/bin;
Open VS , in VS terminal execute the below command.
code --extensions-dir "new_directory_path"
Install the required extension.
All Done.
Note:Dont forget to vote the answer
According to this page, after installing VS Code we should make a language profilers folder like this:
mkdir code_profiles
cd code_profiles
mkdir code-ruby
cd code-ruby
mkdir exts
mkdir data
For Windows, I prepared a batch file (.bat) for each language I work on, it contains this line:
Start "" "D:\programs\VSCode\code.exe" --extensions-dir D:\programs\VSCode\code_profiles\code-python\exts --user-data-dir D:\programs\VSCode\code_profiles\code-python\data .
This is for Python. If I work on PHP, I will make code-php folder, then make exts and data folders in it and prepare another batch file for PHP, just like the one I made for python.
I put this batch file on the main project folder then double click on it to run VS Code with the preferred profile.
I just upgraded from Win7 to Win10 and I noticed the following change, that I don't explain for now.
I used to checkout my source code on in a mounted linux drive (\myremote\myaccount\ as X:)
before I was able to open visual studio 2008 solution (.sln file) and build but since the upgrade to Win10, devenv fails when I double click on a sln, saying that:
The following files were specified on the command line:
X:\blahblah\myproject\myproject.sln
These files could not be found and will not be loaded
but I can open and save that sln file using a text editor.
Note that my devenv run as Administrator.
Any idea ?
I've got a problem with Visual Studio console application created in Ubuntu 15.04. When I try to run c# program in Visual Studio in Windows 10 I get an error "visual project does not contail any commands in project.json and cannot be start". How to fix that?
I have only json file but I don't have any sln and csproj.
The easiest solution: create new, empty console app and paste content (.cs) files from linux repo to it. Build and compile.
Remember to resolve conflicts which may occur (libs used in linux environment may be problematic in windows).
I have the project gmock and am trying to put it into my solution which is in a tfs source control. The project file is in a subdirectory, but when I put it in as a shelveset, and then try and unshelve it, it fails to generate the subdirectory and thus doesn't have a project.
Any idea why this is happening and how to get around this?
Test pass with my enviroment (TFS2015 VS2015). Which step you got different result with me
Step1: Add new project 'Consolepzz' in the test subfolder
Step2: Put the project in a shelveset aaa (you'd better to check the "Preserve Pending changes locally")
Step3: Unshelve the changes (Don't select undo all in the actions)
Step4: Finally found your project in the pending changes and check in it. Double check it in the solution Explorer. The project should added under the solution in source control.
To add all of the gmock test framework to the project's tf source control, I went to the command line for Visual Studio. Link from the start page are:
VS2013 x64 Native Tools Command Prompt
VS2013 x86 Native Tools Command Prompt
VS2013 x64 Cross Tools Command Prompt
VS2013 ARM Cross Tools Command Prompt
or run a cmd prompt and run "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" with one of the following parameters: amd64|x86|x86_amd64|x86_arm
This will call the appropriate vcvars*.bat file which will setup the correct path which will include the tf.exe file.
Then I went to the directory that I wanted to add and typed:
tf add . /recursive
I initially thought that this would add it to the repository, but it just marks it to be added like in git.
And that's it. Now I can shelve my solution and have it recover elsewhere intact.