我想使用SharpDX庫,我必須自己編譯源代碼。 我可以使用Net40配置輕鬆地從他們的GitHub編譯最新的源代碼。 現在我想用編譯後的項目在我自己的項目,我發現下面這樣做: https://github.com/sharpdx/SharpDX/issues/379使用從源代碼編譯的SharpDX?
這導致我做以下步驟:
- 下載並解壓SharpDX源代碼爲「./SharpDX」
- 打開文件「./SharpDX/SharpDX.sln」
- 建立在配置管理與配置Net40的SharpDX源代碼
與以下內容創建文件 「./MyProject/Common.targets」:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <!-- set the location of SharpDX source code --> <SharpDXLocation Condition="'$(SharpDXLocation)' == ''">..\SharpDX</SharpDXLocation> <!-- the new property to include references automatically (as it was in old SharpDX.targets) --> <SharpDXIncludeReferences>true</SharpDXIncludeReferences> <!-- (optional) override DirectX version --> <SharpDXDirectXVersion>DirectX11</SharpDXDirectXVersion> <!-- disable usage of signed assemblies, as you won't have the needed private key to build them --> <SharpDXNoSigned>true</SharpDXNoSigned> </PropertyGroup> <Import Project="$(SharpDXLocation)\Build\SharpDX.targets" /> <Import Project="$(SharpDXLocation)\Build\SharpDX.Toolkit.targets" /> </Project>
與以下內容創建文件 「./MyProject/SharpDXHelper.csproj」:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="BuildTarget"> <Import Project="Common.targets" /> <Target Name="BuildTarget"> <Message Text="Building command for SharpDXHelper" Importance="high" /> </Target> <Target Name="Rebuild"> <Message Text="Rebuilding command for SharpDXHelper" Importance="high" /> </Target> <Target Name="Clean"> <Message Text="Cleaning command for SharpDXHelper" Importance="high" /> </Target> </Project>
- 打開文件「.MyProject/SharpDXHelper.csproj」與Visual Studio。
如果我展開「參考」的「./MyProject/SharpDXHelper.csproj」的一部分,我看到一個警告圖標所需的參照,該警告是這樣的:
警告13找不到引用的組件'SharpDX'。 SharpDXHelper
我不明白我做錯了什麼,爲什麼它沒有找到正確的組件? 我意識到「Toolkit」部分已經消失,我期望那些加載失敗,但我不希望其他人失敗。
據我的理解,如果我將SharpDXHelper.csproj作爲依賴添加到其他任何項目中,我應該能夠毫無問題地使用SharpDX庫,我對這個問題正確嗎?
所產生的問題的圖像可以在這裏找到: http://puu.sh/dfmP4/c6ac1165ed.png
我接受了您的建議,並將添加到了現有的項目文件中,並且違背了我的預期,它實際上起作用了。當然,如果沒有Toolkit API,應該可能會在某個時候更新。無可否認,我添加了導入的項目文件是爲了與NuGet(我拿出的)一起工作而設計的,所以這可能有助於解決這個問題。當我再次醒來時,我將看到_why_它與該項目文件一起工作,而不是與我所做的那個一起工作。 –
ManIkWeet
2014-12-03 22:24:36