Solved

VS 2013 the command copy exited with code 1

Posted on 2016-08-09
8
52 Views
Last Modified: 2016-09-06
I've converted a rather large VB.Net project to C# in Visual Studio 2013. The only error left is in my macro in my post build. The post-build command line is:

copy "$(ProjectDir)MSI\ReadMe.rtf" "$(TargetDir)"
copy "$(ProjectDir)MSI\rtfEULA.rtf" "$(TargetDir)"

I get the error:

Error      1      The command "copy "MSI\ReadMe.rtf" ""
copy "MSI\rtfEULA.rtf" """ exited with code 1.      PMTools

If you notice the $(ProjectDir) and the $(TargetDir) appear to be missing the variables. I have opened up the edit post-build and clicked on the Macro... button to list the available macros values. Both macros have the proper value in them. So somewhere they are going blank during the build of the project?
0
Comment
Question by:dvonderburg
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

by:CraigYellick
ID: 41749315
Sounds like the build process is getting confused and not initializing the variables. Create a new solution and try the macros there -- no doubt they'll work just fine. It's something about your specific solution.

Here's a thread I found about the problem. No definitive solution, unfortunately.
http://stackoverflow.com/questions/985900/tfs-msbuild-projectdir-blank-or-random

Is the solution under version control? In the above thread one guy wrote:

I branched an existing project and $(ProjectDir) kept the old directory in the newly branched code. But that's because I had some compiling errors. Once every project in the solution compiled without errors, $(ProjectDir) changed to the correct path.

Not exactly your problem but might point toward a configuration error somewhere in the background.

-- Craig
0
 
LVL 1

Author Comment

by:dvonderburg
ID: 41749576
Craig - you're correct that a newly created solution will perform the action in the post-build. I am still researching and have yet to find a solution. I am following links in your lead.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 41751698
$(TargetDir) will get the setting from the entry to 'Output Directory' in the Configuration-General page.

while 'Output Directory' is a relative path (relative to Project Directory) the $(TargetDir) was translated as an absolute path. note, you may get a build warning if the output directory doesn't end with a back-slash.

in the post-build event page you can check the current values for the macros by clicking into the edit line, then open the drop-down and choose 'Edit...'. in the following dialog page, there is a button 'Macros>>' where you can see the current Setting of all internal and external variables. note, that the current configuration you have chosen will change the results.

Sara
0
 
LVL 1

Author Comment

by:dvonderburg
ID: 41757902
Sara - the issue is the $(TargetDir) in the macro list show the proper path as absolute but during compile the path becomes blank. The error results shows "" for the replacement of the $(TargetDir). So somewhere during the compile process it appears that Visual Studio is losing the content of the macro variables.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 32

Expert Comment

by:sarabande
ID: 41758110
do you get this with 'debug' and 'release' configuration?

or are you using  a non-standard configuration?

the variables are permanently set and only change when you select a different project or configuration.

try to use $(ProjectDir)$(Configuration) instead of $(TargetDir). this should be equivalent  if for ever reason vs changed either project or configuration in the post build step, you should get a hint.

if the same error occurs, i would suggest to create a new project from scratch and copy the source files to the new project folder(s). then add the source files to the project as 'existing items'. in the properties you always should use 'all configurations' and use $(configuration) to switch between Debug and Release.

Sara
0
 
LVL 1

Author Comment

by:dvonderburg
ID: 41766139
Sara,

I get this with either configuration. I am not using any non-standard configurations.

Don
0
 
LVL 32

Accepted Solution

by:
sarabande earned 500 total points
ID: 41768602
did you try to use a new clean project?

are you using any build steps or custom build?

if yes, can you post the settings both for debug and release?

Sara
0
 
LVL 1

Author Comment

by:dvonderburg
ID: 41786838
Wow what an adventure. Here is what I discovered.

Any new project would run the macros properly. But the ones I copied over after a C# conversion the macro variables were all blank. When I opened my .csproj file as XML edit I found the issue.

First to open your .csproj file as XML

1. Right click the project and select unload.
2. Next right click the project file and select edit.

Look for:
 
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />

Open in new window

(It will be near the bottom of the file)

This section needs to be just below the close item group:
</ItemGroup>

Open in new window


Mine was relocated after the Project Extensions.

 </ItemGroup>
  <ProjectExtensions>
    <VisualStudio>
      <UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_ConfigurationName="Release" BuildVersion_BuildAction="Build" BuildVersion_BuildVersioningStyle="None.None.Increment.None" BuildVersion_StartDate="2014/8/18" />
    </VisualStudio>
  </ProjectExtensions>
  <PropertyGroup>
    <PostBuildEvent>
    </PostBuildEvent>
  </PropertyGroup>
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
  <Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />
</Project>

Open in new window


After I changed it to be:

<ItemGroup>
    <None Include="Resources\sidebarpmtools.jpg" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />
  <ProjectExtensions>
    <VisualStudio>
      <UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_ConfigurationName="Release" BuildVersion_BuildAction="Build" BuildVersion_BuildVersioningStyle="None.None.Increment.None" BuildVersion_StartDate="2014/8/18" />
    </VisualStudio>
  </ProjectExtensions>
  <PropertyGroup>
    <PostBuildEvent>
    </PostBuildEvent>
  </PropertyGroup>
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Open in new window


Everything works. Thank you Sara for leading me in the right directions. What I did is compare the XML of a working project with mine.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now