PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/Visual Studio/VSSDK/MSBuild/Microsoft.VsSDK.Common.targets

#
MSBuild | 187 lines | 96 code | 36 blank | 55 comment | 0 complexity | 222b787eace03da83a80dd76d9fb1e9d MD5 | raw file
  1
  2<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3<!--
  4*************************************************************************
  5Copyright (c) Microsoft Corporation. All rights reserved.
  6This code is licensed under the Visual Studio SDK license terms.
  7THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  8ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  9IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
 10PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 11*************************************************************************
 12-->
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24  <UsingTask TaskName="FindVsSDKInstallation" AssemblyFile="Microsoft.VsSDK.Build.Tasks.dll" />
 25  <UsingTask TaskName="VSCTCompiler" AssemblyFile="Microsoft.VsSDK.Build.Tasks.dll" />
 26  <UsingTask TaskName="CreateMenuPkgDef" AssemblyFile="Microsoft.VsSDK.Build.Tasks.dll" />
 27
 28  <!--
 29    Set the general properties for this installation of the SDK
 30  -->
 31  <PropertyGroup>
 32    <VsSDKVersion>10.0</VsSDKVersion>
 33    <VSSDKTargetPlatformVersion>10.0</VSSDKTargetPlatformVersion>
 34    <VSSDKTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VsSDKVersion)\VSSDK</VSSDKTargetsPath>
 35    <VSSDKTargetPlatformRegRoot>Software\Microsoft\VisualStudio\$(VSSDKTargetPlatformVersion)</VSSDKTargetPlatformRegRoot>
 36    <VSSDKTargetPlatformRegRootSuffix Condition="'$(VSSDKTargetPlatformRegRootSuffix)' == ''">Exp</VSSDKTargetPlatformRegRootSuffix>
 37  </PropertyGroup>
 38
 39  <Target Name="FindSDKInstallation"
 40        Condition="'$(VsSDKInstall)'==''">
 41    <FindVsSDKInstallation SDKVersion="$(VsSDKVersion)">
 42      <Output TaskParameter="InstallationPath" PropertyName="VsSDKInstall" />
 43      <Output TaskParameter="IncludesPath" PropertyName="VsSDKIncludes" />
 44      <Output TaskParameter="ToolsPath" PropertyName="VsSDKToolsPath" />
 45    </FindVsSDKInstallation>
 46  </Target>
 47
 48  <!--
 49    =======================================================================================================
 50                                                VSCT Compilation
 51    =======================================================================================================
 52  -->
 53  <PropertyGroup>
 54    <VSCTCompileDependsOn>$(VSCTCompileDependsOn);FindSDKInstallation</VSCTCompileDependsOn>
 55    <!--Make sure that the __CTC__ macro is defined. This macro is used in common headers
 56        like vsshids.h, so we need it for every VSCT compilation.-->
 57    <__internal_VSCTDefinitions>__CTC__;_CTC_GUIDS_;$(VSCTDefinitions)</__internal_VSCTDefinitions>
 58    <VsctVerboseOutput Condition="'$(VsctVerboseOutput)' == ''">false</VsctVerboseOutput>
 59  </PropertyGroup>
 60
 61  <Target Name="VSCTCompile"
 62          DependsOnTargets="$(VSCTCompileDependsOn)"
 63          Condition="'$(BuildingProject)' != 'false' And '@(VSCTCompile)' != ''">
 64
 65    <!--Create the list of include path to use for the VSCT compilation-->
 66    <ItemGroup>
 67      <!--First add the user provided folders-->
 68      <_InternalVSCTIncludePath Include="@(VSCTIncludePath)" Condition="'@(VSCTIncludePath)' != ''"/>
 69      <!--Now add the internal folders-->
 70      <_InternalVSCTIncludePath Include="$(VsSDKIncludes)" Condition="'$(VsSDKIncludes)' != ''"/>
 71      <_InternalVSCTIncludePath Include="$(VsSDKIncludes)\office10" Condition="'$(VsSDKIncludes)' != ''"/>
 72    </ItemGroup>
 73
 74    <VSCTCompiler AdditionalIncludeDirectories="@(_InternalVSCTIncludePath)"
 75                  IntermediateDirectory="$(IntermediateOutputPath)"
 76                  Definitions="$(__internal_VSCTDefinitions)"
 77                  NoLogo="true"
 78                  OutputFile="%(VSCTCompile.FileName).cto"
 79                  Source="%(VSCTCompile.Identity)"
 80                  Verbose="$(VsctVerboseOutput)"
 81                  SDKVersion="$(VsSDKVersion)">
 82      <Output TaskParameter="TemporaryFiles" ItemName="_TemporaryVsctCompilerFiles"/>
 83    </VSCTCompiler>
 84
 85    <!--Record the VSCT compile CTO outputs for the Clean task.-->
 86    <ItemGroup>
 87      <FileWrites Include="$(IntermediateOutputPath)%(VSCTCompile.FileName).cto" Condition="Exists('$(IntermediateOutputPath)%(VSCTCompile.FileName).cto')"/>
 88      <FileWrites Include="@(_TemporaryVsctCompilerFiles)" />
 89    </ItemGroup>
 90  </Target>
 91
 92  <!--
 93    =======================================================================================================
 94                                            Force AppId to refresh menu cache
 95    =======================================================================================================
 96  -->
 97  <!-- The goal of this target is to force a change in a Menu entry of a pkgdef file when a .vsct file is updated to force VS to pick up the new .cto -->
 98  <Target Name="CreateMenuPkgDef"
 99        Inputs="@(VSCTCompile)"
100        Outputs="$(PkgdefFileWithMenuEntry)"
101        DependsOnTargets="$(CreateMenuPkgDefDependsOn)"
102        AfterTargets="VSCTCompile"
103        BeforeTargets="PrepareForRun">
104
105    <CreateMenuPkgDef PkgdefFile="$(PkgdefFileWithMenuEntry)" VsctFile="%(VSCTCompile.FullPath)" Condition="'$(PkgdefFileWithMenuEntry)'!=''"/>
106  </Target>
107
108
109  <!--
110    ============================================================
111                                        _VsixCleanRecordFileWrites
112
113    Save the list of all files written to disk by the VSIX targets so that it can be used for "Clean" later.
114
115    Files written in prior builds are not removed from Clean cache.
116    ============================================================
117    -->
118  <Target
119       Name="_VsixCleanRecordFileWrites"
120       AfterTargets="IncrementalClean">
121
122    <!-- Read the list of files deployed by prior builds from disk. -->
123    <ReadLinesFromFile File="$(IntermediateOutputPath)$(VsixCleanFile)">
124      <Output TaskParameter="Lines" ItemName="_VsixCleanPriorFileWrites"/>
125    </ReadLinesFromFile>
126    
127    <!--
128        Merge list of files from prior builds with the current build and then
129        remove duplicates.
130        -->
131    <RemoveDuplicates Inputs="@(_VsixCleanPriorFileWrites);@(_VsixDeployCurrentFileWrites)">
132      <Output TaskParameter="Filtered" ItemName="_VsixCleanUniqueFileWrites"/>
133    </RemoveDuplicates>
134
135    <!-- Make sure the directory exists. -->
136    <MakeDir Directories="$(IntermediateOutputPath)"/>
137
138    <!-- Write merged file list back to disk, replacing existing contents. -->
139    <WriteLinesToFile
140        File="$(IntermediateOutputPath)$(VsixCleanFile)"
141        Lines="@(_VsixCleanUniqueFileWrites)"
142        Overwrite="true" />
143
144  </Target>
145  
146  <!--
147    =======================================================================================================
148                                         Clean Deployed Vsix Extension Files
149    =======================================================================================================
150  -->
151  <PropertyGroup>
152    <VsixCleanFile Condition="'$(VsixCleanFile)'==''">$(MSBuildProjectFile).VsixDeployedFileListAbsolute.txt</VsixCleanFile>
153    <ShouldCleanDeployedVsixExtensionFiles Condition="'$(ShouldCleanDeployedVsixExtensionFiles)'==''">true</ShouldCleanDeployedVsixExtensionFiles>
154  </PropertyGroup>
155  <Target Name="CleanDeployedVsixExtensionFiles"
156          BeforeTargets="AfterClean"
157          Condition="$(ShouldCleanDeployedVsixExtensionFiles)">
158
159    <!-- Read the list of files deployed by prior builds from disk. -->
160    <ReadLinesFromFile File="$(IntermediateOutputPath)$(VsixCleanFile)">
161      <Output TaskParameter="Lines" ItemName="_VsixCleanPriorFileWrites"/>
162    </ReadLinesFromFile>
163
164    <!-- Remove duplicates. -->
165    <RemoveDuplicates Inputs="@(_VsixCleanPriorFileWrites)">
166      <Output TaskParameter="Filtered" ItemName="_VsixUniqueCleanPriorFileWrites"/>
167    </RemoveDuplicates>
168
169    <Delete Files="@(_VsixUniqueCleanPriorFileWrites)" TreatErrorsAsWarnings="true">
170      <Output TaskParameter="DeletedFiles" ItemName="_VsixCleanFilesDeleted"/>
171    </Delete>
172
173    <!-- Create a list of everything that wasn't deleted for some reason. -->
174    <ItemGroup>
175      <_VsixCleanRemainingFileWritesAfterIncrementalClean Include="@(_VsixUniqueCleanPriorFileWrites)" Exclude="@(_VsixCleanFilesDeleted)"/>
176    </ItemGroup>
177
178    <!-- Write new list of current files back to disk, replacing the existing list.-->
179    <WriteLinesToFile
180        File="$(IntermediateOutputPath)$(VsixCleanFile)"
181        Lines="@(_VsixCleanRemainingFileWritesAfterIncrementalClean)"
182        Condition="'@(_VsixCleanPriorFileWrites)'!='@(_VsixCleanRemainingFileWritesAfterIncrementalClean)'"
183        Overwrite="true"/>
184    
185  </Target>
186
187</Project>