Shahed
Shahed

Reputation: 73

How can I make sure only *.exe or *.dll file goes to output folder and any other build files goes to intermediate folder VS2012?

I created a C# project on VS2012 and I want that the output folder will only contain the .exe/.dll file and any other files that are created when building the project will go to the intermediate folder.

I have a property sheet that defines the intermediate location.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <BUILD_ROOT>f:\test</BUILD_ROOT>
    <BUILD_INTERMEDIATE>f:\test</BUILD_INTERMEDIATE>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <IntermediateOutputPath>$(BUILD_INTERMEDIATE)\inter\debug\</IntermediateOutputPath>
    <BaseIntermediateOutputPath >$(IntermediateOutputPath)</BaseIntermediateOutputPath >
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <IntermediateOutputPath>$(BUILD_INTERMEDIATE)\inter\Release\</IntermediateOutputPath>
    <BaseIntermediateOutputPath >$(IntermediateOutputPath)</BaseIntermediateOutputPath >
  </PropertyGroup>

</Project>

I imported this property sheet to my project file manuallly

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <Import Project="$(MSBuildProjectDirectory)\PropertySheet.props" />

When I build the project, it creates separate folders for output and intermediate. Intermediate folder contains all the intermediate files along with pdb file. But it also contains the exe file.

But the problem I am facing is, the output folder also contains most of the file which are in intermediate folder too. Such as the pdb, exe, config etc.

Can anyone please help me by explaining what I should do so that only the .exe file will be in output folder and any other build time files will only stay in intermediate folder?

Upvotes: 4

Views: 1382

Answers (2)

Sam Harwell
Sam Harwell

Reputation: 100019

You should instead create an additional "dist" folder (or similar) and copy the exe and dll files to that folder after the build. There are many MSBuild properties and targets that can place files in the output folder, and attempting to change this behavior could break functionality.

Also, if you specify BaseIntermediateOutputPath then you should not specify IntermediateOutputPath. In the case of the properties above, you appear to be trying to use this:

<BaseIntermediateOutputPath>$(BUILD_INTERMEDIATE)\inter\</BaseIntermediateOutputPath>

Upvotes: 2

JeremyK
JeremyK

Reputation: 1113

If I was doing this I would create a bat file to run as a post build script that moved any non dll and exe files.

Upvotes: 1

Related Questions