【发布时间】:2017-06-20 02:00:53
【问题描述】:
我有一个类库,我可以在其中使用以下代码从应用程序路径访问文件。它无法在 azure 上运行,因为它找不到应用程序路径。如何让它在我的本地机器上正常工作。
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?
-
是 Azure WebApp
-
当然在 azure 上找不到!当您部署应用程序时,您不部署源代码只是由构建/发布过程创建的二进制工件
标签: c# azure asp.net-core azure-web-app-service