私は、以下のコードを使用してアプリケーションパスからファイルにアクセスしているクラスライブラリを持っています。それはアプリケーションパスを見つけることができないので、紺碧の上で動作しません。それは私のローカルマシン上で正常に動作するように晴れて仕事をする方法。Azure WebAppでasp.netクラスライブラリプロジェクトのファイルパスを取得する
private string GetProjectPath()
{
string SolutionName = "MyApi.sln";
//Get name of the target project which we want to test
var projectName = typeof(TerminationMatchInquiry).GetTypeInfo().Assembly.GetName().Name;
//Get currently executing test project path
var applicationBasePath = new Uri((typeof(TerminationMatchInquiry).GetTypeInfo().Assembly.CodeBase)).LocalPath;
//Find the folder which contains the solution file. We then use this information to find the
//target project which we want to test
DirectoryInfo directoryInfo = new DirectoryInfo(applicationBasePath);
do
{
var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName));
if (solutionFileInfo.Exists)
{
return Path.GetFullPath(Path.Combine(directoryInfo.FullName, projectName));
}
directoryInfo = directoryInfo.Parent;
}
while (directoryInfo.Parent != null);
throw new Exception($"Solution root could not be located using application root {applicationBasePath}");
}
あなたはAzure WebAppを意味しますか? – Youngjae
はいAzure WebApp – maxspan
もちろん、それは紺碧の上にそれを見つけることはありません!アプリケーションを配備すると、ビルド/公開プロセスによって作成されたバイナリ成果物だけがソースコード**を配備しません。 – Tseng