Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VS 2013 the command copy exited with code 1

Posted on 2016-08-09
8
82 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:Don VonderBurg
  • 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:Don VonderBurg
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 33

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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 1

Author Comment

by:Don VonderBurg
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
 
LVL 33

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:Don VonderBurg
ID: 41766139
Sara,

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

Don
0
 
LVL 33

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:Don VonderBurg
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TimeZone, day light savings, Sql server, asp.net 6 37
jquery + C#.net radiobuttonlist 3 30
jquery tab header text 1 23
Generate Unique ID in VB.NET 21 60
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 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