Sunday, May 06, 2007

XNA, clickonce and MSBuild

The last few months I have been working with XNA off and on. To be honest, mostly working on subversion and clickonce. I don't have a lot to show right now, but that is the nice thing about clickonce is that when I do get more of the game done then it will be automaticly updated.

I am hosting the site from my home computer right now through no-ip.com, so if the site may be down if my computer is off. Secondly, the bootstrap should install all the necessary prerequisites, but if it doesn't then the links are listed below. Here is my current progress. BTW, the images are SUPER large right now, so it might take awhile to download. I am currently working on reducing the size of the images and creating a Xbox 360 version.

XNA Prerequisites for the PC

.NET Framework 2.0
Microsoft XNA Framework Refresh

For those wonder how I got Clickonce to deploy the converted textures and not the source textures, I had to use a little MSBuild hack in the .csproj file. After poking around in MSBuildBinPath and looking through the Microsoft.Common.targets file I realized that some of the Publish functionality can be overriden by overriding MSBuild targets. All I needed to do was add the files to be published in the MSBuild script. Specificly, I needed to override the _DeploymentComputeClickOnceManifestInfo target and add files from my Content directory in my build output. Here is the code to do this:



<!--Override _DeploymentComputeClickOnceManifestInfo Manifest so I can add content files that I need-->
<Target
Name="_DeploymentComputeClickOnceManifestInfo"
Condition="'$(GenerateClickOnceManifests)'=='true'"
DependsOnTargets="_DeploymentGenerateTrustInfo">

<!-- Grab just the serialization assemblies for a referenced assembly. There may also be a symbols file in ReferenceRelatedPaths -->
<CreateItem Include="@(_ReferenceSerializationAssemblyPaths)" Condition="'%(Extension)' == '.dll'">
<Output TaskParameter="Include" ItemName="_SGenDllsRelatedToCurrentDll0" />
</CreateItem>
<CreateItem Include="@(_SGenDllsRelatedToCurrentDll0->'%(FullPath)')">
<Output TaskParameter="Include" ItemName="_SGenDllsRelatedToCurrentDll" />
</CreateItem>

<!-- Flag primary dependencies-certain warnings emitted during application manifest generation apply only to them. -->
<CreateItem Include="@(ReferencePath)" AdditionalMetadata="IsPrimary=true" >
<Output TaskParameter="Include" ItemName="_DeploymentReferencePaths"/>
</CreateItem>

<!-- Create list of items for manifest generation -->
<ResolveManifestFiles
EntryPoint="@(_DeploymentManifestEntryPoint)"
ExtraFiles="$(IntermediateOutputPath)$(TargetName).pdb;$(IntermediateOutputPath)$(TargetName).xml;@(_ReferenceRelatedPaths)"
Files="@(ContentWithTargetPath);@(_DeploymentManifestIconFile);@(AppConfigWithTargetPath)"
ManagedAssemblies="@(_DeploymentReferencePaths);@(ReferenceDependencyPaths);@(_SGenDllsRelatedToCurrentDll)"
NativeAssemblies="@(NativeReferenceFile);@(_DeploymentNativePrerequisite)"
PublishFiles="@(PublishFile)"
SatelliteAssemblies="@(IntermediateSatelliteAssembliesWithTargetPath);@(ReferenceSatellitePaths)"
TargetCulture="$(TargetCulture)">

<Output TaskParameter="OutputAssemblies" ItemName="_DeploymentManifestDependencies"/>
<Output TaskParameter="OutputFiles" ItemName="_DeploymentManifestFiles"/>

</ResolveManifestFiles>

<!--here is where I add the extra content-->
<CreateItem Include="$(OutDir)Content\**\*">
<Output ItemName="ExtraFiles" TaskParameter="Include" />
</CreateItem>

<CreateItem Include="@(ExtraFiles)" AdditionalMetadata="TargetPath=Content\%(RecursiveDir)%(Filename)%(Extension);IsDataFile=false;DependencyType=Install;">
<Output ItemName="_DeploymentManifestFiles" TaskParameter="Include" />
</CreateItem>
<!--END - here is where I add the extra content-->

<CreateProperty Value="ClickOnce">
<Output TaskParameter="Value" PropertyName="_DeploymentManifestType"/>
</CreateProperty>

<!-- Obtain manifest version from ApplicationVersion and ApplicationRevision properties -->
<FormatVersion Version="$(ApplicationVersion)" Revision="$(ApplicationRevision)">
<Output TaskParameter="OutputVersion" PropertyName="_DeploymentManifestVersion"/>
</FormatVersion>

<FormatUrl InputUrl="$(_DeploymentUrl)">
<Output TaskParameter="OutputUrl" PropertyName="_DeploymentFormattedDeploymentUrl"/>
</FormatUrl>

<FormatUrl InputUrl="$(SupportUrl)">
<Output TaskParameter="OutputUrl" PropertyName="_DeploymentFormattedSupportUrl"/>
</FormatUrl>

</Target>