Visual Studio 2015 .NET Core 1.0 Autobuild - debugging

I am working on a .NET Core 1.0 web application in Visual Studio 2015 Community.
Apparently there is an autobuild function, where I should be able to run without debugging (ctrl+F5) and any changes I make to my code should be reflected simply by refreshing the page, but I cannot get this working.
Any changes I make to my views is reflected with a page refresh regardless of whether or not I am running with or without debugging (F5 or ctrl+F5), but any changes I make to controllers or other code is not.
When I run with or without debugging, I get a command prompt that shows up.
If I run the project without debugging and then try and build, I get the following error
Projects\MyProject\bin\Debug\netcoreapp1.0\ASPNET_Core_1_0.dll' for writing -- 'The process cannot access the file 'C:\Users\Adam\Desktop\Visual Studio Projects\MyProject\bin\Debug\netcoreapp1.0\ASPNET_Core_1_0.dll' because it is being used by another process.'
So if I run a project without debugging, I need to close this command prompt, and then re-run with or without debugging to see the changes.
Any help would be greatly appreciated.

I've noticed that if I run my application with IIS Express without debugging, I can get this autobuild function. After I make some changes in my code, I can get that result by pressing F5 in the browser.
However, if I run it directly using WebApplication as target, I cannot get this autobuild function. I have to modify project.json as in the example below:
"tools": {
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"
},
And I have to add some lines in the profiles section to launchSettings.json in the Properties folder:
"dotnet watch": {
"executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
"commandLineArgs": "watch run --server.urls http://*:5000",
"launchBrowser": true,
"launchUrl": "http://localhost:5000/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
After that, I can get this autobuild fuction by selecting dotnet watch as the target, with or without debugging. Thanks to asp.net core and Rehan Saeed.

Related

Visual Studio not running / debugging code anymore

I am using Visual Studio 2019 with .NET extension .
Everything was working fine, i.e all my C# codes and projects were executing fine on F5 when suddenly the options went dead . I am farely new to Visual Studio and cant seem to get my head around this problem . If anyone can suggest anything , it would be of great help.
Basically,
Go to project properties -> Build Tab. Then click Advanced button on the right bottom corner of the pane. Change "Debug Info:" to "full" and click OK.
If it is like that, then change it to "full" like below:
Visual Studio not running / debugging code anymore
Please try these suggestions:
Suggestions
unload your current project by right-click on your project-->Unload your project and then close VS Instance, enter your project path, delete .vs hidden folder, bin, obj folder and then restart your project again.
Then Upload the project, right-click on the project-->set as startup project to test.
reset VS settings by Tools-->Import and Export Settings-->Reset all settings
disable any other third party extensions under Extensions-->Manage Extensions
restart your VS and then rebuild your project
try to create a new empty default project and then test again whether the issue persists, if so, you should try to do a repair in VS Installer, if not, I think the issue is related to your project itself.
same issue in VisualStudio Code, with Dotnet5 API angular MVC application
for me it was the generated main.js file in wwwroot folder. deleted the folder and ran ng build --prod again and got a new one with current code.

Visual Studio 2015 Apache Cordova with TypeScript

I'm using Visual Studio 2015 Update 2 with Apache Cordova Tools Update 8 and TypeScript 1.8.29.
I can't get working the "Build on Save" feature, i tryied to manualy change the property on the project file:
<TypeScriptCompileOnSaveEnabled>true</TypeScriptCompileOnSaveEnabled>
I really need this feature because if VS don't build when i save every time i modify something i must stop debugging, build again, and restart.
I'm sure this should work exactly like less/sass: Modify -> Save -> Build -> Automatic refresh of app.
The part Save -> Automatic/Manual refresh works well, i saw it on css and js.
You need to turn on the "Automatically compile typescript which are not part of a project" option.
open VS->Tools Menu->options->Text Editor->Type Script->Project->check on "automatically compile typescript which are not part of a project".
Please note:
There are two "appBundle.js" files in your project
("/scripts/www/scripts/appBundle.js" and "/www/scripts/appBundly.js"). CompileOnSave only compiles codes to "/scripts/www/scripts/appBundle.js" by default.
You can change the output file by changing the "out" property of "compilerOptions" in tsconfig.json file.

TypeScript only compiles if previously compiled JavaScript file has been deleted

I am using Angular 2 in Visual Studio 2015, inside of an asp .net 4.5 project. When I build and run the project, JavaScript files are created correctly. However, if I make any changes to the TypeScript and recompile, the JavaScript isn't being overwritten. The only way I can get the TypeScript to recompile is by deleting the previous JS file.
I would first suggest opening Visual Studio as Administrator to see if it is a permissions issue, whereby VS2015 cannot overwrite your JS files.
Otherwise, right click on the project in your solution (not the solution itself) and select Properties.
You should have a tab called TypeScript Build as shown in the screenshot below. Ensure that you have Compile on Save checked.
"compileOnSave": true
must be added to tsconfig.json.

How can I have TypeScript build only on save in Visual Studio

When I build the project, it is redundantly building script event though I have script compiling on run/debug. Is there a way to make it only build on save?
If you have installed Web Essentials 2012 extension it is very easy.
In Visual Studio go to Tools -> Options -> Select Web Essentials, Under the TypeScript set "Compile TypeScript on Save" to True
You can set the build type to none and saving the .ts file will still build the .js file. However, the .js file does not get checked in to TFS so when someone gets the project, they would have to open and save every file. This seems to be another issue.

Build->Deploy doesn't work for database projects

I have a database project in Visual Studio 2012. When selecting "Deploy MyDBProj" on the Build menu nothing happens.
When I hit F5 to debug however, the database project is deployed, using the settings in the debug section of the database project properties. This is enabled in by checking the "deploy" checkbox in the solution's configuration manager.
I would like to be able to do a deploy, without starting a debug session. How do I do that?
Note: This is not publishing, which is something else. I want to know how to manually initiate the deploy that is part of the build process. Since the deploy is already done automatically it should be possible to initiate it manually too.
I got an answer from Microsoft at MS Connect:
There was a bug in the version of SSDT that shipped in Visual Studio
2012 in wuich the Deploy menu command appears but is a no-op. This has
since been fixed and is available in the latest version of SSDT:
http://msdn.microsoft.com/en-us/data/hh297027
The only way I can think of doing it (though I haven't tested it) would be to use the command line to do it as outlined at http://msdn.microsoft.com/en-us/library/dd193258(v=vs.100).aspx.
Though once you have your manifest, you can run:
VSDBCMD /a:Deploy /dd:+ /manifest:manifestFileName.dbmanifest
from a command line to deploy your database.
The manifest will contain your target database name, connection string, and so on but you can also specify those as part of the command line instead.

Resources