Where's the "TEMP" folder for Custom Build Steps? - visual-c++

Visual Studio 2010, in my project I made a custom build step which renames a dll file and copies it to other folder. So, Alt+F7, Config props, Custom Build Step / General, command line:
copy /y $(TargetPath) $(TargetName).node
It didn't do anything. Then I also added
ping bat.femei.ro -n 1 -w 5000
It still didn't do anything. It simply flashed a command prompt window for a split second then the window went away. I googled as much as I could concluding that there might be a problem with the folder where the batch file is generated.
I did my best to screenshot that split second with the command prompt and after a boring F7-PrintScreen-PasteInPaint session finally I got
C:\Users\FURAT\AppData\Local\Temp\blablablablablablablablabla.exec.cmd is not recognized as internal or external...
I double checked the directory. It has Everyone permissions set to Allow both Read & Write operations. What's wrong? How do I fix this?

I was unable to find any knobs to tweak temp folder path. It's not Env and it's not in the config either.
What did work however was running VS2010 as Administrator. Now the Custom Build Step works.

Related

Unable to run dotnet under certain directories?

I am using the command: dotnet "myfile.dll"
Initially it was giving me this error: The user's home directory could not be determined. Set the 'DOTNET_CLI_HOME' environment variable to specify the directory to use.
Now after messing around with it, I have moved my files to c:/mydir, and it is giving this error: Failed to initialize CoreCLR, HRESULT: 0x80070057. I found this, but isn't c:/mydir a drive root?
Couple of things I noted:
I am able to run the .dll fine in a different directory.
Both directories contain same files.
The reason I want to run it in c:/mydir is because I am using AWS CodeDeploy, and that is where it copies the files (as far as I know; and the other directories are just the old versions where the files get copied from).
These issues are not linked (the first one I get from running a automated shell script after installation, and the second I get from manually trying to launch the .dll).
If someone could help me solve either one of these issues it would be greatly appreciated.
Try adding Environment=DOTNET_CLI_HOME=/temp to your Service declaration in your .service file. Example syntax:
[Service]
...
Environment=VARNAME=VARCONTENTS
So the actual like would look like this
Environment=DOTNET_CLI_HOME=/temp

How do I fix MSB3073 error in my post-build event?

I'm working on a project that requires that DLLs generated by building my solution to be copied from the bin folder to another folder, both of which are on my machine, in my C drive. I've written a batch file that uses xcopy to accomplish this, which you can see here:
xcopy /s /y /q "C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.dll" "C:\inetpub\wwwroot\AppServer\bin\"
xcopy /s /y /q "C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.pdb" "C:\inetpub\wwwroot\AppServer\bin\"
Now, I've tried numerous iterations of this file, which is located at:
C:\Users\scogan\Desktop\CopyFiles.bat
so my post-build event command line looks like this:
call C:\Users\scogan\Desktop\CopyFiles.bat
I've run this batch file on its own with two text files in folders on my desktop, and it works fine. I've also run it as it is with the files I need to copy on its own, and that works fine, too. However, when I try to run this as a post-build event, I get this output:
1> Organizr -> C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Client\bin\Debug\Organizr.exe
1> File not found - Organizr.Services.dll
1> 0 File(s) copied
1> 0 File(s) copied
1> File not found - Organizr.Services.pdb
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(4291,5): error MSB3073: The command "call C:\Users\scogan\Desktop\CopyFiles.bat" exited with code 4.
I've done some research, and found that error code 4 means that "Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line."
I've also looked up what MSB3073 is, and haven't really found much that can help me there. So, my question is what am I doing wrong? Are the absolute paths messing it up? Any help here is appreciated.
Playing around with different project properties, I found that the project build order was the problem. The project that generated the files I wanted to copy was built second, but the project that was running the batch file as a post-build event was built first, so I simply attached the build event to the second project instead, and it works just fine. Thanks for your help, everyone, though.
Prefer the MsBuild "Copy" task in an AfterBuild target over a post-build event.
Append this Target into your project file and remove the PostBuildEvent.
<Target Name="AfterBuild">
<Copy SourceFiles="C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.*"
DestinationFolder="C:\inetpub\wwwroot\AppServer\bin\"
OverwriteReadOnlyFiles="true"
SkipUnchangedFiles="false" />
</Target>
For what it's worth, the problem in my case was caused by using '/' as the directory separator in a copy command. Must use backslashes.
In my case, the dll I was creating by building the project was still in use in the background. I killed the application and then xcopy worked fine as expected.
The specified error is related to the post built event. Somehow VS tool is not able to copy the files to the destination folder. There can be many reasons for it. To check the exact error cause go to Tools > Option> Project and Solution > Built and run, and change "MsBuild project build output verbosity" to "Diagnostic". It will give you enough information to detect the actual problem.
This is too late but posting my experience for people looking at it later:-
In MS VS 2010 I had the same issue. It got resolved by putting quotes to post build copy command args which contained spaces!
In Project Properties --> Configuration Properties --> Build Events --> Post-Build Event --> Command Line change:
copy $(ProjectDir)a\b\c $(OutputPath)
to
copy "$(ProjectDir)a\b\c" "$(OutputPath)"
If the problem still persists even after putting the after build in the correct project try using "copy" instead of xcopy. This worked for me.
The Post-Build Event (under Build Events, in the properties dialog) of an imported project, had an environment variable which was not defined.
Navigated to Control Panel\All Control Panel Items\System\Advanced system settings to add the appropriate environment variable, and doing no more than restarting VS2017 resolved the error.
Also, following on from #Seans and other answers regarding multiple project races/contentions, create a temp folder in the output folder like so,
and select the project producing the preferred output:
and build (no rebuild/clean) is a speedy solution.
Following thing you should do before to run copy command if you facing some issue with copy command
open solution as a administrator and build the solution.
if you have problem like "0 File(s) copied" check you source and destination path. might you are using wrong path. it would be better if you run the same command in "command prompt" to check whether it is working fine or not.
I solved it by doing the following:
In Visual studio I went in Project -> Project Dependencies
I selected the XXX.Test solution and told it that it also depends on the XXX solution to make the post-build events in the XXX.Test solution not generate this error (exit with code 4).
I've found the issue happens when you have multiple projects building in parallel and one or more of the projects are attempting to copy the same files, creating race conditions that will result in occasional errors. So how to solve it?
There's a lot of options, as above just changing things around could solve the issue for some people. More robust solutions would be...
Restrict the files being copied i.e. instead of xcopy $(TargetDir)*.*"... instead do xcopy "$(TargetDir)$(TargetName).*"...
Catch the error and retry i.e:
:loop
xcopy /Y /R /S /J /Q "$(TargetDir)$(TargetName).*" "somewhere"
if ErrorLevel 1 goto loop
Use robocopy instead of xcopy
You probably won't want to do this as it will increase your build times, but you could reduce the maximum number of parallel project builds to 1 ...
I had the same problem for my Test project. I found out why my post build event wasn't working and that's because I was copying files before running the $(ProjectName).exe command and some of these files were required for Test project itself. Hence, by just moving $(ProjectName).exe as the first command fix the issue.
I faced this issue recently and surprisingly only i was having this problem and none of my team members were facing this issue when building the project code.
On debugging i found that my code directory had spacing issue , It was D:\GIT Workspace\abc\xyz.
As a quick fix i changed it to D:\GITWS\abc\xyz and it solved the problem.
I was getting this error after downloading some source code from Github. Specifically the rust oxide development framework. My problem is that the Steam.ps1 script file, that's used to update some of the dlls from Steam was blocked by the OS. I had to open the files properties an UNBLOCK it. I had not realized this was done to ps1 files as well as exes.
In my case a setting mismatch between Project's Configuration Properties->General->Output Directory setting and Linker->General->Output Directory.
There was a warning about it during linking.
I was facing a similar issue where it said it cannot copy a DLL from my build location to destination. The issue was my project path contained spaces, removing them the error was gone.

Installing Emacs Emulation keybindings -- Invalid VSIX package

I'm trying to install the extension for Visual Studio 2012 that allows emacs key-bindings.
I'm following through the steps here:
Emacs Keybindings in Visual Studio 2012 or 2013
I'm up to step 5:
Run the vsik file as administrator. This is required so the extension
can write Emacs.vsk into the program files folder. I wasn't sure the
best way to do this so I ran a command prompt as admin and then
executed start emacsemulations.vsik from the prompt.
So, running emacsemulations.vsix from an administrator command prompt,
I get the following error "This VSIX package is invalid because it does not contain the file extension.vsixmanifest at the root."
I'm not changing any of the file names inside the package.
I'm thinking this may have something to do with how windows zips up the file -- I'm able to recreate the problem simply by unzipping and rezipping the EmacsEmulation.vsix file without changing the contents of the vsix package.
If anyone has any suggestions on how to fix, or even better, the actual updated vsix file itself, I'd be very grateful!
The issue you have relies on the way you are zipping your file, what you should do is zip all files inside the folder you created (in this case, "EmacsEmulations") when you unzipped it.
Step into the EmacsEmulations folder.
Select all files.
Add to .zip
Rename the .zip output to EmacsEmulations.vsix
I'm trying to get this extension to work too, so good luck!

SVN Error (Can't set file)

Everytime I try to commit files to SVN I got the following error.
Command Commit
Modified D:\Project\src\WebSite\SomePage.aspx.cs
Sending Content D:\Project\AKent\src\WebSite\Test\SomePage.aspx.cs
Commit succeeded, but other errors follow:
Error bumping revisions post-commit (details follow):
Can't set file 'D:\Project\AKent\src\WebSite\Test\SomePage.aspx.cs'
read-write: Access is denied.
After I get this error, SVN doesnt allow me to update or commit anything! And what is really frustrating me is that the project folder is around 2 GB and every night I download it from SVN over and over.
Please help me to fix it! I just wanna know what is wrong with my SVN. I tried reinstalling, didn't fix anything.
I had the same problem but fixed. My solution is:
1. Run Command Prompt as Administrator
2. Navigate to the target working copy
3. svn cleanup
The error
read-write: Access is denied.
indicates that svn can not access the file or can't set all attributes it needs to that file.
Now that either means you have not full access to those files or some other application has the file opened exclusively.
In the first case: make sure that your username has full access to all folders and subfolders of your working copy. Note that on Vista/Win7 it's not enough to be an admin - you have to give yourself full access to such files manually.k
In the second case: disable windows search indexer for your working copy, and exclude the working copy from being scanned by your virus scanner.
If you are sharing a svn versioned folder using samba and running into this issue when acessing it from windows machine, try:
http://tortoisesvn.net/faq.html#samba
Also add to your smb.conf file:
dos filemode = yes
copy the wrong folder (1) to another folder(2)
delete the wrong folder (1)
copy the backup(2) to (1)
Hope this approach works for you too!
I was trying to revert a file but was receiving the error listed in the OP's post. Soony's answer just about worked for me. I cannot comment or edit that answer, so I had to copy their answer and add a small step at the end. S/he deserves all the credit.
Run Command Prompt as Administrator
Navigate to the target working
copy svn cleanup
svn revert [filename]
(the revert did not work in Windows Explorer/TortoiseSVN integrated tools, I had to do it from the cmd line)

Access denied when trying to copy file Windows Vista

I have this batch that needs to run that the user has to execute that will copy a simple xml file. However, everything works fine on windows 2000/XP. However, on windows Vista I get an error 'Access Denied".
Even when I try and copy the file just using windows explorer on Vista I get the same error.
Is there anything I can do to make this file copy. Do I have to add any extra code to my bat file to enable copying of this file?
Many thanks.
#ECHO OFF
REM copy config file to the windows/system32
copy config.xml c:\windows\system32\DataLinks.xml
I'm guessing it's because you're trying to change windows\system32. Vista, 7 and future version of Windows require elevated privileges in order to change system32.
Do you really need to put this file in system32? If it's an arbitrary location, why not pop it in the user's AppData directory (%AppData%\DataLinks.xml)?
AppData is a standard directory that's been around since Windows 2000 that hides in the user's Documents and Settings or Users folder (depending on the version). It's a hidden but user-editable folder, intended for application settings that the user needs to be able to get to but is mostly only going to be used by your code.
You need elevated privs to copy to %windir%\system32
You shouldn't copy your config data into %windir% at all. That's for Windows. Use %AppData%.
If you do copy to %windir%, use the %windir% variable and don't hardcode the path C:\Windows
JS Bangs is right; use %windir% variable. Most of the time when you do that it won't give any errors.
Example:
#ECHO OFF
REM copy config file to the windows/system32
copy config.xml %windir%\system32\DataLinks.xml
But while would you? Just put it in any other one. Like AppData what was already said:
#ECHO OFF
REM copy config file to the windows/system32
copy config.xml %appdata%\DataLinks.xml

Resources