34

msbuild を使用して csproj プロジェクトをビルドしようとしていますが、nuget.targets が見つからないという不平を言う、あらゆる種類の奇妙な問題があります。

MSbuild で最も単純なコマンド ライン ビルドを実行します。

Msbuild Project.csproj

そして、それは通常の dev フォルダーでは機能しますが、別のフォルダーの場所では、次のエラーで失敗します。

error MSB4019: The imported project "C:\BuildAgent\work\CableSense\.nuget\nuget.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

そのパス ( C:\BuildAgent\work\CableSense\.nuget\nuget.targets) は実際には間違っており、作業後のフォルダー (work\somefolder\cablesense) がありませんが、その理由がわかりません。さらに奇妙なことに、ソリューションの一部である別のプロジェクトをビルドすると、それは機能します。それはこのプロジェクトだけです。

csproj は、nuget.targets ファイルの場所を次のように指定します。

<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

SolutionDir は次のように定義されます。

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>

これは、機能する他のプロジェクトと同じです。何か案は?

4

3 に答える 3

57

ああ!これを投稿した後、問題が見つかりました。基本的に、プロジェクトには他のプロジェクトへの依存関係がありました。これらの関連プロジェクトの csproj ファイルは少し間違っていました - そしてこれが SolutionDir としてありました:

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\CableSense\</SolutionDir>

それが問題を引き起こしました!これが他の誰かに役立つことを願っています。今、自分の質問に答えるのは気分が悪いです。

于 2012-12-20T15:51:32.623 に答える
3

OK, so I got the same error now recently but the solution worked out to be different for me.

In the Build Definition, under Source Settings, I had the Source Control Folder set to the directory of the actual project instead of the root folder for the solution.

I know this is an old answered thread, but this might help someone who made the same mistake I did.

于 2014-12-02T09:40:19.170 に答える