2017-04-07 12 views
0

我想發佈具有引用其他的自定義組件(這是另一個NuGet包)的組件使用TFS組件爲獲得一個NuGet包來自VSTS的工作項目信息。生成正確nuspec文件......使用組件引用真實TFS時NullReference例外組件

當我發表我的包,並嘗試使用這個DLL,我得到每當我的代碼試圖訪問TFS NullReference例外。

要清楚,我已經發布這個插件NuGet包包含:

Plugin.dll組裝。

該組件具有一定的功能,這檢索TFS工作項的信息,做任何工作

而這些功能在TFSUtilities.dll組件(這也有它自己的NuGet包),它具有以下功能:訪問TFS 。

而這組件(TFSUtilities.dll)引用acutual TFS組件如 'Microsoft.TeamFoundation.WorkItemTracking.Client'
'Microsoft.TeamFoundation.WorkItemTracking.Proxy'
'Microsoft.TeamFoundationTestManagement.Common'。 ...等

所以在發佈我的Plugin.dll nuget包後,當我嘗試從另一個解決方案引用此包並調用Plugin.dll中的函數來訪問TFS工作項時,它只是給了我System.NullReferenceException試圖訪問TFS。

我想我不會產生正確的nuspec文件雖然。下面是我對plugin.dll nuspec文件的內容。

<?xml version="1.0" encoding="utf-8"?> 
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> 
    <metadata> 
    <id>Plugin</id> 
    <version>1.0.0.0</version> 
    <title>Plugin</title> 
    <authors>Custom</authors> 
    <owners>BCustom</owners> 
    <requireLicenseAcceptance>false</requireLicenseAcceptance> 
    <description>Contains custom assemblies</description> 
    <language>en-US</language> 

    <dependencies> 
     <dependency id="TFSUtilities" version="1.6.72" /> 
    </dependencies> 
    </metadata> 
    <files> 
    <file src="..\bin\Release\Plugin.dll" target="lib\net452\Plugin.dll" /> 

    <file src="..\bin\Release\Plugin.dll" target="build\Plugin.dll" /> 
    <file src="..\bin\Release\TFSUtilities.dll" target="build\TFSUtilities.dll" /> 
     <file src="..\bin\Release\Microsoft.TeamFoundation.WorkItemTracking.Client.dll" target="build\Microsoft.TeamFoundation.WorkItemTracking.Client.dll" /> 
     <file src="..\bin\Release\Microsoft.TeamFoundation.Client.dll" target="build\Microsoft.TeamFoundation.Client.dll" /> 
     <file src="..\bin\Release\Microsoft.VisualStudio.Services.Client.dll" target="build\Microsoft.VisualStudio.Services.Client.dll" /> 
     <file src="..\bin\Release\Microsoft.VisualStudio.Services.Common.dll" target="build\Microsoft.VisualStudio.Services.Common.dll" /> 
     <file src="..\bin\Release\Microsoft.TeamFoundation.Common.dll" target="build\Microsoft.TeamFoundation.Common.dll" /> 
     <file src="..\bin\Release\Microsoft.VisualStudio.Services.WebApi.dll" target="build\Microsoft.VisualStudio.Services.WebApi.dll" /> 
    </files> 
</package> 

我擡起頭,在互聯網上,它看起來像我可能需要增加更多的庫,例如WITDataStore64.dll或更多的東西,但我不完全得到它在說什麼。任何人都可以幫我解決這個問題嗎?僅供參考,我們的工作項目都在網上VSTS。

+0

什麼是詳細代碼? –

+0

你能分享你得到的詳細的異常信息嗎? –

回答

0

請按以下步驟去做:

  1. 創建一個類庫項目(如TFSUtilities)
  2. 安裝Microsoft.TeamFoundationServer.ExtendedClient
  3. 複製你的代碼粘貼到該項目
  4. 構建這個項目
  5. 包裝這一項目通過調用Nuget.exe包[項目文件的路徑(TFSUtilities.csproj)

TFSUtilities.nuspec代碼:

<?xml version="1.0" encoding="utf-8"?> 
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> 
    <metadata> 
    <id>TFSUtilities</id> 
    <version>1.0.0</version> 
    <title>TFSUtilities</title> 
    <authors>WS</authors> 
    <owners>WS</owners> 
    <requireLicenseAcceptance>false</requireLicenseAcceptance> 
    <description>TFS API</description> 
    <copyright>Copyright © 2017</copyright> 
    <dependencies> 
     <dependency id="Microsoft.TeamFoundationServer.ExtendedClient" version="15.112.1" /> 
     <dependency id="Newtonsoft.Json" version="8.0.3" /> 
    </dependencies> 
    </metadata> 
</package> 
  • 發佈此包
  • 創建一個類庫項目(例如插件)
  • 以前安裝包(TFSUtilites)
  • 通過調用的NuGet編碼
  • 包裝這一項目。exe文件包[項目文件路徑(Plugin.csproj)]
  • Plugin.nuspec代碼:

    <?xml version="1.0" encoding="utf-8"?> 
    <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> 
        <metadata> 
        <id>Plugin</id> 
        <version>1.0.0</version> 
        <title>Plugin</title> 
        <authors>starain</authors> 
        <owners>starain</owners> 
        <requireLicenseAcceptance>false</requireLicenseAcceptance> 
        <description>Description</description> 
        <copyright>Copyright © 2017</copyright> 
        <dependencies> 
         <dependency id="Newtonsoft.Json" version="8.0.3" /> 
         <dependency id="TFSUtilities" version="1.0.0" /> 
        </dependencies> 
        </metadata> 
    </package> 
    
  • 安裝插件包到其他項目,並使用它。
  • +0

    TFSUtilities項目已經安裝了ExtendedClients軟件包,但仍然失敗。 – JNA

    +0

    @JNA你的步驟是什麼?你可以分享OneDrive的簡單項目嗎?順便說一句:我添加nuspec代碼到我的答案,你可以檢查它。 –