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.
Related
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
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.
I'm making a plugin framework and to aid development i am changing the output path of each plugin to the shell project. However, in doing so it breaks razor intellesense in any .cshtml files in that particular project.
Is there any way around this bug?
I set the output path back to default (\bin)
and set up a post build event
xcopy "$(ProjectDir)\bin" "$(SolutionDir)Frontline_UPF\Modules\$(ProjectName)" /i /s /y /q
I couldnt use $(TargetDir) since it added a \ to the end and that prevented xcopy from working.
During a recent backup/restore cycle I've realized that I managed to omit the 'tmp' directories from within the '.svn' directories, and because of this I can't update my working copies. The problem goes away if I manually create a new, empty 'tmp' directory so I am looking for a way to recursively go through each folder, find '.svn' ones and create a 'tmp' folder inside them.
As I don't want to mess up the existing folders I thought I's ask for help before I did something silly :)
Comments/suggestions will be appreciated, thanks!
PS: This is on a Windows machine so sadly Bash and other unix utilities are not present.
The script above doesn't work on my on Windows 7 machine. The "dir /b /s .svn" doesn't get all dirs, I get a "File Not Found" error.
I changed the script to have /ad in addition to select directories only and that works! Here is the srcipt which works for me.
#echo off
for /f "usebackq delims=" %%I in (`dir /ad /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)
Depends on how many there are.
List the directories with
dir/B/S .svn >dirs.bat
Edit dirs.bat in your editor of choice. Add md at the beginning of each line (since each line begins with something like C: you can use a fairly dumb editor - including notepad - to change C: to md C: ). Add /tmp to the end of each line (replace .svn with .svn\tmp). Save. Run the BAT file
Job done.
Here's how to automate the entire process. Put the following in a file like fixtmp.cmd:
#echo off
for /f "usebackq delims=" %%I in (`dir /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)
I have a solution in VS2008 (C#) that contains multiple projects. I just retooled some of the .csproj files for our build process, and suddenly while coding Project B won't recognize references from Project A in the class code...think the red squiggly lines under a variable type I've created. However, building the solution generates no errors. Why's it behaving like this?
I would suggest that you clear your Visual Studio temp files - it can often get confused about project structures and require a fresh start.
First, quit out of VS completely and restart it. If the problem is still there, find your VS cache folder and delete it, and then do a rebuild.
For help finding your cache folder, check this post.
When VS starts acting strangely wonky, and I can't find a logical fix, I kill Visual Studio, and manually do a 'clean' by deleting all of the bin/obj folders.
I have a batch file that does this for me quicker than I could do it manually. I place this in my solution directory, and all my projects are found in subdirectories.
rem "%%~dpa" says: Give me the (d)drive and (p)path of the (a, %%a) file.
rem However, our dir /a:d will result in only listing folders...
rem The final "%%a" is just appending the 'file' (diretory name) to the
rem drive-and-path string
for /f %%a in ('dir /b /a:d *.*') do call :process "%%~dpa%%a"
pause
goto :eof
:process
echo Looking in %1
cd "%1"
if EXIST "%1\bin" (
echo Found 'bin' - it's gone now.
rd /s /q "%1\bin"
)
if EXIST "%1\obj" (
echo Found 'obj' - it's gone now.
rd /s /q "%1\obj"
)
cd ..
Another solution
If the other answers regarding clearing Visual Studio cache, .NET Cache, and
ensuring references are valid don't work, try this one.
Based on the source, and trying this solution, I've had success.
Deleting the visual studio solution cache folder
Close out of all instances of visual studio
Locate the .vs hidden folder within your solution.
Delete the entire hidden .vs folder.
Rebuild the solution
-- Source
In your Project Properties from B, make sure Project A is checked under dependencies.
Make sure both projects are being built in the Configuration Manager
(right click on the solution and then click “Configuration Manager”)
You might also hover over the redline or just build again to see if you get anymore details. C# and VB are both pretty good at telling you why they not happy.
I've removed the reference from the project which classes were not recognized and re-added this reference. Everything got fixed.
Double check that you made the classes you are referencing public. Visual Studio doesn't do it automatically when you make a new class and I sometimes forget.