我發現這裏在計算器上其他職位與我的問題我遇到處理之外的文件,例如:還有Include Files in MSBuild that are not a part of the project 我想和大家分享,我是代碼包括的MSBuild
MSBuild: Deploying files that are not included in the project能夠在閱讀這些帖子後創建,並尋求一些幫助,爲什麼它可能不工作?
詳細說明什麼是錯誤的以及我打算做什麼。我正在使用Visual Studio 2012和TFS 2012.
我有一個名爲CreateMyFiles.bat的批處理文件,我想要做的是執行此操作,然後將其輸出的文件(它將它們輸出到我的Includes/Javascript/Bundled文件夾),並將它們包含在MSBuild的部分構建中(以便將它們部署到目標IIS服務器)。
當我在本地Visual Studio中編輯我的本地.csproj,並將下面的代碼添加到文件底部並重新加載時,我可以右鍵單擊我的web項目,選擇「發佈」,然後選擇我的本地基於文件的發佈配置文件確實將我的文件部署到了正確的位置。有效!
然後我檢查了我的代碼到TFS,然後去了TFS上的「構建」,並排隊了一個新的構建。果然,我能夠看到文件輸出到構建服務器上的同一目錄。現在,我並不是100%確定MSBuild,但我注意到,就像當我點擊本地發佈時一樣,它也在構建服務器上創建了一個_publishedWebsite文件夾(源代碼上方的目錄)。問題是,在這個發佈的網站文件夾中,我手動創建的文件不存在。此外,在構建完成後轉到目標Web服務器,很不幸沒有我想要的文件。
所以看起來好像我要手動選擇發佈,下面的代碼工作,但如果我用TFS排隊構建,它不起作用。 MSBuild是否使用發佈?這可能是它不起作用的原因嗎?
這裏是我放在我的.csproj文件中的代碼:
<Target Name="CustomCollectFiles">
<Exec Command="CreateMyFiles.bat" /> <!-- Generate Files -->
<ItemGroup>
<!-- Create an identity called _CustomFiles, and associate it to the files I created -->
<_CustomFiles Include="Includes\JavaScript\Bundled\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Includes\JavaScript\Bundled\*%(Filename)%(Extension) </DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<!-- Hook into the pipeline responsible for gathering files and tell it to add my files -->
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
我真的卡在這,想尋求一些幫助,爲什麼這些文件可能不會去。我懷疑MSBuild不使用發佈,這就是爲什麼它在本地工作(因爲我選擇發佈)?
非常感謝您的幫助
UPDATE 試過這種按下面的評論,但此時的文件甚至沒有出現(所以它似乎沒有即使是現在運行的任務)。任何想法爲什麼?我輸入了這個權利嗎?
<Target Name="CustomCollectFiles">
<Exec Command="CreateMyFiles.bat" />
<!-- Generate Files -->
<ItemGroup>
<!-- Create an identity called _CustomFiles, and associate it to the files I created -->
<_CustomFiles Include="Includes\JavaScript\Bundled\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Includes\JavaScript\Bundled\*%(Filename)%(Extension) </DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<!-- Hook into the pipeline responsible for gathering files and tell it to add my files -->
<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
CustomCollectFiles;
$(PipelineCollectFilesPhaseDependsOn);
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>
更新2 當我走在上面的代碼,並把它變成我的pubxml文件,然後執行實際的發佈,它的工作原理,但據我所知,我們的工藝是剛剛排隊構建來自TFS。當簡單地排隊構建時,是否可以鉤入上面的代碼塊?或者我需要發佈?
因此,當我在TFS中構建隊列時,它會*執行發佈?有什麼辦法可以運行上面的代碼而不必發佈? – NullHypothesis 2014-10-07 13:52:49
除非您使用上面顯示的MSBuild參數告訴它,否則不發佈。你可以做類似的事情,但你上面的代碼是針對發佈我假設由於「FilesForPackagingFromProject」在代碼 – 2014-10-07 14:14:35
謝謝所以我認爲正在發生的是,當我排隊時,我看到文件被推送到發佈目標僅僅是因爲ms構建活動,對吧?在出版方面是否有任何傷害? – NullHypothesis 2014-10-07 14:20:51