Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VS 2013 the command copy exited with code 1

Posted on 2016-08-09
8
Medium Priority
?
206 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
[X]
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
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

by:Craig Yellick
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 35

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 35

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 35

Accepted Solution

by:
sarabande earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

636 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