Configure MSBuild output path

前端 未结 2 1348
[愿得一人]
[愿得一人] 2020-12-14 17:30

There is a Windows Forms (NET 3.5) project, foo.csproj, with localized resources files. I use MSBuild to build the project and create a deployment structure:



        
相关标签:
2条回答
  • 2020-12-14 18:02

    Resource files generation and copy is done in an internal MSBuild process during the build: GenerateSatelliteAssemblies and CopyFilesToOutputDirectory. They are copied in the output directory.

    As far as I know, you can't modify this behavior.

    You have to move your resources files after the build step. I would advise to use the Move task from MSBuild community tasks.

    <MSBuild Projects="foo.csproj" Properties="Configuration=Release;OutputPath=..\deploy\foo" Targets="Build" />
    
    <CreateItem Include="..\deploy\foo\**\*.resources.dll">
        <Output TaskParameter="Include" ItemName="ResourcesToMove" />
    </CreateItem>
    
    <Move SourceFiles="@(ResourcesToMove)" DestinationFiles="@(ResourcesToMove->'..\deploy\locales\%(RecursiveDir)\%(Filename)%(Extension)')"/>
    
    0 讨论(0)
  • 2020-12-14 18:03

    Using MSBuild command line, you can specify the output path like below:

    C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe <path_to_project_file> /t:Build /p:OutDir=c:\custom_build_out\;Configuration=PRODUCTION;Platform=x64
    

    Note:

    1. If you change the order of specifying the OutDir property for /p, this doesn't work.
    2. The OutDir property is for specifying a full path to an alternate directory. OutputPath is for a relative directory.
    3. It has to have a project name + build configuration name in the custom build output path as MSBuild does not append these things to the OutDir.
    0 讨论(0)
提交回复
热议问题