• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

VS 2013 the command copy exited with code 1

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
Don VonderBurg
Asked:
Don VonderBurg
  • 4
  • 3
1 Solution
 
Craig YellickDatabase ArchitectCommented:
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
 
Don VonderBurgPresident/CEOAuthor Commented:
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
 
sarabandeCommented:
$(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
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
Don VonderBurgPresident/CEOAuthor Commented:
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
 
sarabandeCommented:
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
 
Don VonderBurgPresident/CEOAuthor Commented:
Sara,

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

Don
0
 
sarabandeCommented:
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
 
Don VonderBurgPresident/CEOAuthor Commented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now