Include files from Team build output folder into X

2019-02-24 20:23发布

问题:

I'm trying to do Continuous Integration using TFS 2010 for a Windows Phone 7.1 project. There are 2 resource projects (Win32 Project for localisation) and the main Windows phone project.

I have copied the project output of above 2 projects to a folder in the main WP project (inside 'MUI' folder) , and also marked the files as 'content' in build action. All works well when building and running the WP7 project from Visual Studio 2010.

But when I try to build the projects using TFS 2010 build system , the build fails with the following error "Xap packaging failed. Object reference not set to an instance of an object" . After researching about the error, i found that when files are build on the TFS agent machine, the TFS binaries(output folder) folder doesn't have an "MUI" folder but the output of the 2 resources projects get directly copied into the binaries folder, and hence failing the build.

Also i have noticed that if i add/include the files directly to the main WP project, the TFS build succeeds.(in other words fails if i configure project output to copy to WP7 project folder. Since TFS builds everything to 'binaries' folder)

How can I include those files within the WP7 XAP file (referring them) from the TFS binaries folder? (using MSBuild task? ) and the same should work with local builds within VS2010 also.

Also are there other ways to do this?

thx

回答1:

Solved the problem by setting the output path of the resources project to the output path of the WP7 project and then used XapFilesInputCollection to include them in the xap.

Also changed the referred paths in WMAppManifest.xml for application title .

Changes made :

a. Added/Replaced the OutDir tag in each of the resource projects files .

<OutDir>$(SolutionDir)$(SolutionName)\bin\Debug</OutDir>

This copies the resource project output to main project output AppResLib.dll and AppResLib.dll.040b.mui

b. Then in the main Windows Phone project file (.csproj) added

      <Target Name="AfterCompile">
         <ItemGroup>
           <XapFilesInputCollection Include="$(OutDir)\AppResLib.dll"/>
           <XapFilesInputCollection Include="$(OutDir)\AppResLib.dll.040b.mui"/>
         </ItemGroup>
   </Target>

This works in both VS 2010 build as well as TFS 2010 Build system.

Referring to Silverlight MSBuild Task - execute command line after Xap copied to ClientBin



回答2:

This is how I solved it using SlowCheetah.


Tested on:

Locations

  • Locally
  • Build servers (TFS 2012)

Visual Studio versions

  • Visual Studio 2010
  • Visual Studio 2012

Silverlight versions

  • Silverlight 4

Process

  • Use SlowCheetah to create the transformations
  • Update the Visual Studio project with the following information at the end of the project:

    <PropertyGroup>
        <XapPackagerDependsOn>
          TransformAllFiles;
          IncludeTransformedFileInXapFile;
          $(XapPackagerDependsOn);
        </XapPackagerDependsOn>
    </PropertyGroup>
    <Target Name="IncludeTransformedFileInXapFile">
        <ItemGroup>
          <XapFilesInputCollection Include="$(OutDir)YOUR-FILES.CONFIG" />
        </ItemGroup>
    </Target>
    
    • Make sure the config files and the transformation files do not get copied to the output folder: