Xamarin Forms Android Emulator not attaching to debug - visual-studio

I'm running Visual Studio 2017 with Xamarin Forms using a shared project type. When I run the Android emulator in debug mode it will work properly once, but as soon as I make a code change, it does not attach to the code unless I delete the virtual device, re-create it and restart VS.
Clearing the cache in the Android Emulator Manager does not work, neither does cleaning and rebuilding. What am I missing?

Try Below Solution:-
create text file and write below code in it :-
FOR /F "tokens=" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
Now save this file with SamplefileName.bat with .bat extension.
Make sure while saving "select Save As Type" option as "All Files".
Now you need to place this .bat file into your Solution Directory where your project .SLN file resides.
This .bat file will delete the bin and obj folders from the project solution
Next step is now run this bat file whenever you make code changes and you want the debugger should work after the changes.
You may not need to close and reopen the emulator/ Genymotion vertual device

Related

Why can't I delete the contents of the 'INetCache' folder from the command prompt?

I'm using Windows 10 and need to update a batch file to clear the contents of folder at "C:\Users\myUserName\AppData\Local\Microsoft\Windows\INetCache". This is the folder that holds cache for Internet Explorer.
I would have thought the command was simply as follows:
DEL /S /F /Q C:\Users\myUserName\AppData\Local\Microsoft\Windows\INetCache\*
This command executes without issue, but when I look at the contents of the folder via Windows Explorer, it still has stuff in it. I say "stuff" because while it looks like a bunch of files, they don't behave like typical files. For instance, I cannot see these files when when I use "dir" on the command prompt no matter which flags I utilize. And when I examine the properties of these files, there is barely any information associated with them.
Why isn't my DEL command clearing out these files?
Screenshot of "files" still present in my INetCache folder
Screenshot of the properties of one of these files
I found that using the "rmdir" command instead of the "del" command resolved my issue.
rmdir "C:\Users\myUserName\AppData\Local\Microsoft\Windows\INetCache" /s /q
open txt and save .bat file
DEL /S /F /Q C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache\*
pause

In Visual Studio 2013 copy files to the release directory only

I have some files in my project that are used for unit testing, and than files that will be used in the actual release.
Currently have 'Copy to output directory' copy always turned on.
Is there a more direct way to send only certain files to the 'Release' directory and others to the 'Debug' directory when building?
I ended using the command line build events property in the MAIN/Solution project.
yourproject > properties > build events
Pre build event command line
First i cleaned out the directory
rd /s /q "$(TargetDir)Configs"
Post-build event command line
Next on Debug, copy all.
And on Release, del everyting that was for testing.
if "$(ConfigurationName)"=="Debug" (
xcopy "$(ProjectDir)Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\_notes.*"
)
if "$(ConfigurationName)"=="Release" (
xcopy "$(ProjectDir)Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\test*.*"
del "$(TargetDir)Configs\_notes.*"
)
IN the test Project, used the same PRE command.
Had to change the POST command a little.
if "$(ConfigurationName)"=="Debug" (
xcopy "$(SolutionDir)$(SolutionName)\Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\_notes.*"
)
if "$(ConfigurationName)"=="Release" (
xcopy "$(SolutionDir)$(SolutionName)\Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\test*.*"
del "$(TargetDir)Configs\_notes.*"
)
I think this could be slimmed down, but its working.

Remove an item from the Start menu using batch file

I want to remove an item from the start menu using batch scripts in admin mode ofcourse
I tried the following
Set scut=C:\users
del /s /q /f %scut%\name of shortcut.lnk
but it does not seem to be working. can anyone please point me to the right direction.
I will make the question a bit clear by providing screen shot
here actually I want to remove Notepad or Microsoft Word 2010 or notepad++.exe using command prompt
I'm not sure if I got your question right...
If you want to delete a shortcut from the windows start menu you must know where the .lnk files are located:
Per-user menu: C:\Users[username]\AppData\Roaming\Microsoft\Windows\Start Menu
All user's menu: C:\ProgramData\Microsoft\Windows\Start Menu
So the code should be something link this:
DEL /Q "C:\Users\[username]\AppData\Roaming\Microsoft\Windows\Start Menu\shortcut.lnk"
or
DEL /Q "C:\ProgramData\Microsoft\Windows\Start Menu\shortcut.lnk"
If the .lnk is located in a subfolder you'll obviously have to modify the path ;-)
Set scut=C:\Users
cd /d %scut%
del /s /q /f "name of shortcut.lnk"
So, change directory to %scut% and recursively delete the shortcut in double quotes (because spaces).
Try http://superuser.com next time, it's more IT Pro audience oriented.
EDIT. Apparently del doesn't follow SYMLINKS, so "%scut%\All Users\" becomes a particular case, just add it at the end.
cd /d "%scut%\All Users"
del /s /q /f "name of shortcut.lnk"

How to solve "The directory is not empty" error when running rmdir command in a batch script?

I am making a batch script and part of the script is trying to remove a directory and all of its sub-directories. I am getting an intermittent error about a sub-directory not being empty. I read one article about indexing being the culprit. I disabled WSearch but I eventually got the error again. Here's the command:
rmdir /S /Q "C:\<dir>\"
I experienced the same issues as Harry Johnston has mentioned. rmdir /s /q would complain that a directory was not empty even though /s is meant to do the emptying for you! I think it's a bug in Windows, personally.
My workaround is to del everything in the directory before deleting the directory itself:
del /f /s /q mydir 1>nul
rmdir /s /q mydir
(The 1>nul hides the standard output of del because otherwise, it lists every single file it deletes.)
I'm familiar with this problem. The simplest workaround is to conditionally repeat the operation. I've never seen it fail twice in a row - unless there actually is an open file or a permissions issue, obviously!
rd /s /q c:\deleteme
if exist c:\deleteme rd /s /q c:\deleteme
I just encountered the same problem and it had to do with some files being lost or corrupted. To correct the issue, just run check disk:
chkdsk /F e:
This can be run from the search windows box or from a cmd prompt. The /F fixes any issues it finds, like recovering the files. Once this finishes running, you can delete the files and folders like normal.
enter the Command Prompt as Admin and run
rmdir /s <FOLDER>
I had a similar problem, tried to delete an empty folder via windows explorer. Showed me the not empty error, so I thought I try it via admin cmd, but none of the answers here helped.
After I moved a file into the empty folder. I was able to delete the non empty folder
As #gfullam stated in a comment to #BoffinbraiN's answer, the <dir> you are deleting itself might not be the one which contains files: there might be subdirectories in <dir> that get a "The directory is not empty" message and the only solution then would be to recursively iterate over the directories, manually deleting all their containing files... I ended up deciding to use a port of rm from UNIX. rm.exe comes with Git Bash, MinGW, Cygwin, GnuWin32 and others. You just need to have its parent directory in your PATH and then execute as you would in a UNIX system.
Batch script example:
set PATH=C:\cygwin64\bin;%PATH%
rm -rf "C:\<dir>"
Im my case i just moved the folder to root directory like so.
move <source directory> c:\
And then ran the command to remove the directory
rmdir c:\<moved directory> /s /q
I had "C:\Users\User Name\OneDrive\Fonts", which was mklink'ed ( /D ) to "C:\Windows\Fonts", and I got the same problem. In my case
cd "C:\Users\User Name\OneDrive"
rd /s Fonts
Y (to confirm the action)
helped me. I hope, that it helps you too ;D
What worked for me is the following. I appears like the RMDir command will issue “The directory is not empty” nearly all the time...
:Cleanup_Temporary_Files_and_Folders
Erase /F /S /Q C:\MyDir
RMDir /S /Q C:\MyDir
If Exist C:\MyDir GoTo Cleanup_Temporary_Files_and_Folders
The reason rd /s refuses to delete certain files is most likely due to READONLY file attributes on files in the directory.
The proper way to fix this, is to make sure you reset the attributes on all files first:
attrib -r %directory% /s /d
rd /s %directory%
There could be others such as hidden or system files, so if you want to play it safe:
attrib -h -r -s %directory% /s /d
rd /s %directory%
Windows sometimes is "broken by design", so you need to create an empty folder, and then mirror the "broken folder" with an "empty folder" with backup mode.
robocopy - cmd copy utility
/copyall - copies everything
/mir deletes item if there is no such item in source a.k.a mirrors source with
destination
/b works around premissions shenanigans
Create en empty dir like this:
mkdir empty
overwrite broken folder with empty like this:
robocopy /copyall /mir /b empty broken
and then delete that folder
rd broken /s
rd empty /s
If this does not help, try restarting in "recovery mode with command prompt" by holding shift when clicking restart and trying to run these command again in recovery mode
one liner:
if exist folder rmdir /Q /S folder
I'm using this in a NPM script like so (Javascript) :
//package.json
"scripts": {
"start": "parcel --no-cache",
"clean": "if exist dist rmdir /Q /S dist",
"deploy": "npm run clean && parcel build --no-source-maps && firebase deploy"
},
Open CMD as administrator
chkdsk c: /F /R
Press the “Y” key if asked to check your disk the next time your system restarts.
Restart the machine. After that just delete the folder.
The easiest way I found to do this is:
rm -rf dir_name
it worked on zsh - macOS, it should work on windows cmd as well.
if you need to delete a folder on Windows with a batch file you will need to use PowerShell and this is how it is done:
rmdir .\directory_name\ -Recurse
Similar to Harry Johnston's answer, I loop until it works.
set dirPath=C:\temp\mytest
:removedir
if exist "%dirPath%" (
rd /s /q "%dirPath%"
goto removedir
)
Force delete the directory (if exists)
Delete.bat
set output_path="C:\Temp\MyFolder"
if exist %output_path% (
echo Deleting %output_path%
attrib -r /s /d %output_path%
rd /s /q %output_path%
)
I've fixed this before my making sure there wasn't extra whitespace in the name of the directory I was deleting. This is more of a concern when I had the directory name contained within a variable that I was passing to RD. If you're specifying your directly in quotes then this isn't helpful, but I hope that someone like me comes along with the same problem and sees this. RD /S /Q can work, as I noticed the issue started happening when I changed something in my batch script.
I can think of the following possible causes:
there are files or subdirectories which need higher permissions
there are files in use, not only by WSearch, but maybe by your virus scanner or anything else
For 1.) you can try runas /user:Administrator in order to get higher privileges or start the batch file as administrator via context menu. If that doesn't help, maybe even the administrator doesn't have the rights. Then you need to take over the ownership of the directory.
For 2.) download Process Explorer, click Find/Find handle or DLL... or press Ctrl+F, type the name of the directory and find out who uses it. Close the application which uses the directory, if possible.

visual studio 2010 debug build broken

strange 1 here..
have a solution with multiple projects in (mvc2 application, class library etc).
the solution will not build in debug mode anymore. 1 if the projects isnt building its DLL anymore (although it creates reference dll's in the bin\debug folder).
this gives me the error: Metadata file 'C:[solution]\bin\Debug[myprojectname].dll' could not be found.
if i put the build into release, all my dll's build and solution correctly loads.
any idea why this is happening?
thanks
Check Build - Configuration Manager.
For each project in your solution you can check if it should be build and some more things.
I found that sometimes a project just got unchecked so it wont build,....
If you have lots of Metadata errors in build output, there is usually one compilation error way at the bottom of the list. Do you have any compiler directives in your code (like #ifdef DEBUG that would be causing problems?
Sometimes VS gets confused and I have to go manually clean the bin folders for it to recompile. I usually create a batch file and put it in the root of my solution to do this for me.
Clean.bat:
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
I run this whenever VS starts misbehaving. If that doesn't work then it's time for a reboot.

Resources