2

Ich habe vor kurzem wechselte zu NuGet neuester empfohlene Methode, die eine `packages.json‘ Datei für Projekte verwendet:NuGet Paket für Restore-Lösung nicht (nur auf der Kommandozeile)

{ 
    "dependencies": { 
    "Newtonsoft.Json": "9.0.1", 
    "RestSharpSigned": "105.2.3" 
    }, 
    "frameworks": { 
    "net45": {} 
    }, 
    "runtimes": { 
    "win": {} 
    } 
} 

Dies funktioniert gut in Meine lokale Visual Studio-Umgebung, aber der CI-Server kann das Projekt nicht mehr erstellen.

Was seltsam ist, dass ich die Pakete erfolgreich für die Lösung gestellt werden sehen, aber auf zu bauen, hat MSBuild keine Ahnung, wo diese DLLs sind und alle Verweise auf sie fehlschlagen:

Paket wiederherstellen Succeeding:

09:48:07 Updating NuGet.exe to 3.4.4-rtm-final. 
09:48:07 Update successful. 
09:48:08 MSBuild auto-detection: using msbuild version '14.0' from 
     'C:\Program Files (x86)\MSBuild\14.0\bin'. 
09:48:09 Restoring packages for C:\jenkins-test\...\Client\Client.NET45.project.json... 
09:48:10 Installing RestSharpSigned 105.2.3. 
09:48:10 Installing Newtonsoft.Json 9.0.1. 
09:48:13 Committing restore... 
09:48:13 Committing restore... 
09:48:13 C:\jenkins-test\...\Client\Client.NET45.csproj 
09:48:13 Restore completed in 3715ms.09:48:13 Installed: 
09:48:13  2 package(s) to C:\jenkins-test\...\Client\Client.NET45.csproj 

Körperbau des Versagens

09:48:14 Microsoft (R) Build Engine version 14.0.23107.0 
... 
09:48:14 Project "C:\jenkins-test\...\Client.sln" (1) is building 
     "C:\jenkins-test\...\Client\Client.NET45.csproj" (2) on node 1 (default targets). 
09:48:14 PrepareForBuild: 
09:48:14 Creating directory "bin\Debug\net45\". 
09:48:14 Creating directory "obj\Debug\". 
09:48:14 CoreCompile: 
09:48:14 C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /doc:bin\Debug\net45\Client.xml /define:DEBUG;TRACE;NET45 /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Runtime.Serialization.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Client.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /utf8output API\API.Authentication.cs API\API.Configuration.cs API\API.Parameters.cs API\API.Requests.cs API\API.Utilities.cs API\Authentication\AccessTokenStatus.cs API\Authentication\AuthenticationStatus.cs API\Authentication\BasicAuthenticationToken.cs API\Authentication\IAccessToken.cs API\Authentication\OauthAccessToken.cs "API\Custom Exceptions\APIRequestException.cs" "API\Custom Exceptions\NotWaitingException.cs" API\ExtensionMethods\ExtensionMethods.IAPIResourceView.cs API\ExtensionMethods\ExtensionMethods.IAPIResource_WithDataEndpoint.cs API\ExtensionMethods\ExtensionMethods.IAPIType.cs API\ExtensionMethods\ExtensionMethods.Reference.cs API\ExtensionMethods\ExtensionMethods.Rest.cs API\ExtensionMethods\ExtensionMethods.Rest.InferredType.cs API\JsonConverters\AnalyzeReContractResolver.cs API\JsonConverters\AnalyzeReJsonConverter.cs API\JsonConverters\ComplexNestedObjectConverter.cs API\JsonConverters\DerivedResourceCreationConverter.cs API\JsonConverters\JsonCreationConverter.cs "API\JsonConverters\JsonCreationConverter[T].cs" API\JsonConverters\JsonSerializerExtensionMethods.cs API\JsonConverters\LayerViewCreationConverter.cs API\JsonConverters\PortfolioViewSerializer.cs API\JsonConverters\ReferenceConverter.cs API\JsonConverters\UriConverter.cs API\LargeDataUpload\AdaptiveBufferedBytesProducer.cs API\LargeDataUpload\BufferedBytes.cs API\LargeDataUpload\BufferedBytesFromStreamProducer.cs API\LargeDataUpload\BufferedBytesResizer.cs API\LargeDataUpload\BufferedBytesToStringProducer.cs API\LargeDataUpload\BufferProducerException.cs API\LargeDataUpload\GZipBufferedBytesProducer.cs "API\LargeDataUpload\Internal Classes\LargeDataUpload.AsyncParameters.cs" "API\LargeDataUpload\Internal Classes\LargeDataUpload.Exceptions.cs" "API\LargeDataUpload\Internal Classes\LargeDataUpload.HandleUploadInSessionStrategy.cs" "API\LargeDataUpload\Internal Classes\LargeDataUpload.Parameters.cs" "API\LargeDataUpload\Internal Classes\LargeDataUpload.StatusReponse.cs" API\LargeDataUpload\IProducerConsumerBuffer.cs API\LargeDataUpload\LargeDataUpload.cs API\LargeDataUpload\ProducerConsumerBuffer.cs API\Rest\IRestResponse.cs API\Rest\Method.cs API\Rest\Parameter.cs API\Rest\ParameterType.cs API\Rest\ResponseStatus.cs API\Rest\RestResponse.cs "API\Rest\RestResponse[T].cs" Attributes\APITypeAliasAttribute.cs Attributes\GreaterThanAttribute.cs Attributes\LessThanAttribute.cs Attributes\NotEmptyAttribute.cs Attributes\NotNullAttribute.cs Attributes\NumericValidationAttribute.cs Attributes\PropertyAlias.cs Attributes\ResolvedInViews.cs Attributes\ServerGenerated.cs Attributes\ServerHasDefault.cs Attributes\ServerHasDefaultEmptyObject.cs Attributes\ValidationAttribute.cs Model\APITypes\APIResource_WithDataEndpoint.cs Model\APITypes\APIType_Polymorphic.cs Model\APITypes\Interfaces\IAPIResource_WithDataEndpoint.cs Model\APITypes\Interfaces\IAPI_Polymorphic.cs Model\APITypes\Interfaces\IStoredAPIResource.cs Model\APITypes\OptionsResponse.cs "Model\APITypes\REST Entities\ResourceStringBuilder.cs" "Model\APITypes\REST Entities\SubResources\CommandSubResource.cs" "Model\APITypes\REST Entities\SubResources\DataSubResource.cs" "Model\APITypes\REST Entities\SubResources\LargeDataSubResource.cs" "Model\APITypes\REST Entities\SubResources\ResourceEndpoint.cs" "Model\APITypes\REST Entities\SubResources\SubResource[T].cs" Model\APITypes\ServerError.cs Model\APITypes\StoredAPIResource.cs Model\APITypes\StoredAPIResource_Polymorphic.cs Model\Common\APIResource.cs Model\Common\APIResourceView\AggregationMethod.cs Model\Common\APIResourceView\BaseAPIResourceView.BackAllocations.cs Model\Common\APIResourceView\BaseAPIResourceView.CoMetrics.cs Model\Common\APIResourceView\BaseAPIResourceView.cs Model\Common\APIResourceView\BaseAPIResourceView.ExceedanceProbabilities.cs Model\Common\APIResourceView\BaseAPIResourceView.TailMetrics.cs Model\Common\APIResourceView\IAPIResourceView.cs Model\Common\APIResourceView\State.cs Model\Common\APIResourceView\TargetCurrencyDefault.cs Model\Common\APIResourceView\YELTSimulationResult.cs Model\Common\APIResourceView\YLTSimulationResult.cs Model\Common\APIType.cs Model\Common\CollectionResponse\CollectionResponseMeta.cs "Model\Common\CollectionResponse\CollectionResponse[T].cs" "Model\Common\CollectionResponse\ICollectionResponse[T].cs" Model\Common\Interfaces\IAPIResource.cs Model\Common\Interfaces\IAPIType.cs Model\Common\MonetaryUnit.cs "Model\Common\Perspective\Internal Classes\Perspective.BasicPerspective.cs" "Model\Common\Perspective\Internal Classes\Perspective.CustomizablePerspective.cs" "Model\Common\Perspective\Internal Classes\Perspective.LossNetOfTermsPerspective.cs" Model\Common\Perspective\Perspective.cs Model\Common\Perspective\Perspective.Enum.cs Model\Common\Perspective\Perspective.Static.cs Model\Common\Reference\IReference.cs "Model\Common\Reference\IReference[T].cs" Model\Common\Reference\Reference.cs "Model\Common\Reference\Reference[T].cs" Model\Common\Reinstatement.cs Model\Common\TaskStatus.cs Model\Metrics\BackAllocations\BackAllocations.cs Model\Metrics\CoMetrics\CoMetrics.Context.cs Model\Metrics\CoMetrics\CoMetrics.cs Model\Metrics\ExceedanceProbabilities\ExceedanceProbability.Context.cs Model\Metrics\ExceedanceProbabilities\ExceedanceProbability.cs Model\Metrics\TailMetrics\TailMetrics.Context.cs Model\Metrics\TailMetrics\TailMetrics.cs Model\Resources\Agent.cs Model\Resources\AnalysisProfile.cs "Model\Resources\Analysis\Abstract Base Classes\Analysis.cs" Model\Resources\Analysis\VendorPortfolioAnalysis.cs Model\Resources\Analysis\VendorTreatyAnalysis.cs "Model\Resources\Distributions\Abstract Base Classes\ContinuousDistribution.cs" "Model\Resources\Distributions\Abstract Base Classes\CustomDistribution.cs" "Model\Resources\Distributions\Abstract Base Classes\DiscreteDistribution.cs" "Model\Resources\Distributions\Abstract Base Classes\Distribution.cs" Model\Resources\Distributions\BinomialDistribution.cs Model\Resources\Distributions\CustomFrequencyDistribution.cs Model\Resources\Distributions\CustomSeasonalityDistribution.cs Model\Resources\Distributions\CustomSeverityDistribution.cs Model\Resources\Distributions\DiracDistribution.cs Model\Resources\Distributions\LogNormalDistribution.cs Model\Resources\Distributions\NegativeBinomialDistribution.cs Model\Resources\Distributions\NormalDistribution.cs Model\Resources\Distributions\ParetoDistribution.cs Model\Resources\Distributions\PoissonDistribution.cs Model\Resources\Distributions\UniformDistribution.cs Model\Resources\Distributions\UniformIntDistribution.cs Model\Resources\EventCatalog.cs Model\Resources\ExchangeRateProfile\ExchangeRateProfile.cs "Model\Resources\ExchangeRateProfile\Internal Classes\ExchangeRateProfile.ExchangeRateDateRule.cs" "Model\Resources\ExchangeRateProfile\Internal Classes\ExchangeRateProfile.ExchangeRateLatestRule.cs" "Model\Resources\ExchangeRateProfile\Internal Classes\ExchangeRateProfile.ExchangeRateSelectionRule.cs" Model\Resources\ExchangeRateTable.cs Model\Resources\File.cs "Model\Resources\Layers\Abstract Base Classes\Layer.cs" "Model\Resources\Layers\Abstract Base Classes\Layer_WithLossSets.cs" "Model\Resources\Layers\Abstract Base Classes\Layer_WithTerms.cs" "Model\Resources\Layers\Abstract Base Classes\Layer_XL.cs" Model\Resources\Layers\AggregateQuotaShare.cs Model\Resources\Layers\AggXL.cs Model\Resources\Layers\CatXL.cs Model\Resources\Layers\Filter.cs Model\Resources\Layers\Generic.cs Model\Resources\Layers\IndustryLossWarranty.cs Model\Resources\Layers\Interfaces\ILayer.cs Model\Resources\Layers\Interfaces\ILayer_WithAggregateTerms.cs Model\Resources\Layers\Interfaces\ILayer_WithLossSets.cs Model\Resources\Layers\Interfaces\ILayer_WithOccurrenceTerms.cs Model\Resources\Layers\Interfaces\ILayer_WithReinstatements.cs Model\Resources\Layers\Interfaces\ILayer_WithTerms.cs Model\Resources\Layers\Nested.cs Model\Resources\Layers\QuotaShare.cs Model\Resources\Layers\SurplusShare.cs Model\Resources\LayerViews\ILayerView.cs "Model\Resources\LayerViews\ILayerView[T].cs" Model\Resources\LayerViews\LayerViews.cs "Model\Resources\LayerViews\LayerView[T].cs" "Model\Resources\LossFilters\Abstract Base Classes\AttributeFilter.cs" "Model\Resources\LossFilters\Abstract Base Classes\ComparisonFilter.cs" "Model\Resources\LossFilters\Abstract Base Classes\ExpressionFilter.cs" "Model\Resources\LossFilters\Abstract Base Classes\LossFilter.cs" Model\Resources\LossFilters\AndFilter.cs Model\Resources\LossFilters\AnyFilter.cs Model\Resources\LossFilters\AnyOfFilter.cs Model\Resources\LossFilters\GTFilter.cs Model\Resources\LossFilters\LTFilter.cs Model\Resources\LossFilters\OrFilter.cs Model\Resources\LossFilters\RangeFilter.cs "Model\Resources\LossSets\Abstract Base Classes\LossSet.cs" "Model\Resources\LossSets\Abstract Base Classes\LossSet_WithCurrency.cs" "Model\Resources\LossSets\Abstract Base Classes\LossSet_WithData.cs" Model\Resources\LossSets\ELTLossSet.cs Model\Resources\LossSets\Interfaces\ILossSet_Simulated.cs Model\Resources\LossSets\Interfaces\ILossSet_WithEventCatalog.cs Model\Resources\LossSets\Interfaces\ILossSet_WithSeasonality.cs "Model\Resources\LossSets\Internal Classes\BinaryYELTConverter.cs" "Model\Resources\LossSets\Internal Classes\InuringTerms.cs" "Model\Resources\LossSets\Internal Classes\LossSetProfile.cs" "Model\Resources\LossSets\Internal Classes\LossType.cs" "Model\Resources\LossSets\Internal Classes\NestedLayerLossSet.Perspective.cs" "Model\Resources\LossSets\Internal Classes\TreatyLossSet.Treaty.cs" Model\Resources\LossSets\LoadedLossSet.cs Model\Resources\LossSets\NestedLayerLossSet.cs Model\Resources\LossSets\ParametricLossSet.cs Model\Resources\LossSets\PortfolioLossSet.cs Model\Resources\LossSets\TreatyLossSet.cs Model\Resources\LossSets\YELTLossSet.cs Model\Resources\LossSets\YLTLossSet.cs "Model\Resources\OptimizationView\Internal Classes\OptimizationView.Candidate.cs" "Model\Resources\OptimizationView\Internal Classes\OptimizationView.CandidateParameter.cs" "Model\Resources\OptimizationView\Internal Classes\OptimizationView.DomainEntry.cs" "Model\Resources\OptimizationView\Internal Classes\OptimizationView.Result.cs" Model\Resources\OptimizationView\OptimizationView.cs "Model\Resources\Portfolios\Abstract Base Classes\Portfolio.cs" Model\Resources\Portfolios\DynamicPortfolio.cs Model\Resources\Portfolios\StaticPortfolio.cs Model\Resources\PortfolioView\PortfolioView.cs Model\Resources\Simulation\Simulation.cs Model\Resources\Simulation\StaticSimulation.cs Utilities\Formatting.cs Utilities\IfNotNullExtensionMethod.cs Utilities\ReflectionUtilities.cs "Utilities\Simulation Monitor\AsyncRequestMonitor.cs" "Utilities\Simulation Monitor\SimulationStatus.cs" "Utilities\Simulation Monitor\SimulationStatusMonitor.cs" Utilities\TypeResolver.cs Properties\AssemblyInfo.cs Properties\Settings.Designer.cs "C:\Temp\.NETFramework,Version=v4.5.AssemblyAttributes.cs" 
09:48:23 API\API.Configuration.cs(9,20): error CS0246: The type or namespace name 
'RestSharp' could not be found (are you missing a using directive or an assembly reference?) 
... 
09:48:23 API\ExtensionMethods.IAPIType.cs(2,7): error CS0246: The type or namespace name 
'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) 
... 
09:48:25  0 Warning(s) 
09:48:25  258 Error(s) 
09:48:25 
09:48:25 Time Elapsed 00:00:01.27 

Das ist mein Build-Skript jetzt:

nuget.exe update -Self 
nuget.exe restore Client.sln 
MSBuild.exe Client.sln /p:Configuration=Release 

Nie hatten Probleme mit ihm vor der Wiederherstellung Lösungen für die packages.json Methode Schalt

Von dem, was ich in die Build verknüpft (die removing the references from the csproj files erfordert) bekommen, die referenzierten DLLs von NuGet nicht (sie sagen kann, nirgendwo in der sehr langen Zeile CoreCompile erscheinen).

Muss ich etwas in meinem CI-Build-Skript ändern, damit es wieder funktioniert?

Antwort

2

Damit MSBuild die Assemblys aus der Datei project.json auflösen kann, wird custom MSBuild task verwendet, das auf dem Computer installiert ist, sodass es für MSBuild global verfügbar ist.

auf dem lokalen Computer werden diese im Verzeichnis:

C:\Program Files (x86)\MSBuild\Microsoft\NuGet 

Ich glaube, diese Dateien, die von Visual Studio installiert sind 2015

Es gibt auch eine Microsoft.NuGet.ImportBefore.props Datei im Verzeichnis:

C:\Program Files (x86)\MSBuild\14.0\Imports\Microsoft.Common.Props\ImportBefore 

Es gibt auch eine Microsoft.NuGet.ImportAfter.target s Datei im Verzeichnis:

C:\Program Files (x86)\MSBuild\14.0\Imports\Microsoft.Common.Targets\ImportAfter 

Welche ist, wie die NuGet .props und .targets Dateien werden in MSBuild importiert und auf jedes Projekt zur Verfügung.

+0

Danke, ich habe keine "Nuget" oder "14.0 \ Imports" Ordner in meiner MSBuild Installation auf Jenkins, das würde erklären, warum es nicht funktioniert. Gibt es eine Standardmethode, um diese zu konfigurieren, ohne Visual Studio auf dem CI-Computer zu installieren? (Sollte ich sie einfach von einem Computer kopieren, der sie hat?) – Alain

+0

Ich würde versuchen, die Dateien zu kopieren und sehen, ob das funktioniert. Ich kenne kein Installationsprogramm, das nur diese Dateien installieren würde. –

+0

'C: \ Programme (x86) \ MSBuild \ 14.0 \ Imports \ Microsoft.Common.Props \ ImportBefore' war alles Jenkins benötigt (hatte nicht einmal die anderen zwei Ordner auf meinem Rechner), aber es funktioniert jetzt. Vielen Dank! – Alain