Skip to content

Commit c059487

Browse files
committed
Make sure the output path exists. For .NET 5, it is not in the same place
1 parent 4f9317d commit c059487

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

DotNETDepends/PublishedWebProject.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,29 @@ private void ReadProjectFile(IErrorReporter errorReporter)
110110
if (project.FilePath != null && assemblyName != null)
111111
{
112112
var binRoot = Path.Combine(new string[] { Path.GetDirectoryName(project.FilePath)?? "", "bin", config });
113-
DirectoryInfo dirInfo = new(binRoot);
114-
var dirs = dirInfo.GetDirectories();
115-
string? assemPath = null;
116-
if (dirs.Length == 1)
113+
if (Path.Exists(binRoot))
117114
{
118-
assemPath = Path.Combine(new string[] { binRoot, dirs[0].Name, runtime, "publish", assemblyName });
119-
if (File.Exists(assemPath))
115+
DirectoryInfo dirInfo = new(binRoot);
116+
var dirs = dirInfo.GetDirectories();
117+
string? assemPath = null;
118+
if (dirs.Length == 1)
120119
{
121-
return assemPath;
120+
assemPath = Path.Combine(new string[] { binRoot, dirs[0].Name, runtime, "publish", assemblyName });
121+
if (File.Exists(assemPath))
122+
{
123+
return assemPath;
124+
}
125+
assemPath = Path.Combine(new string[] { binRoot, dirs[0].Name, runtime, assemblyName });
126+
if (File.Exists(assemPath))
127+
{
128+
return assemPath;
129+
}
130+
assemPath = Path.Combine(new string[] { binRoot, dirs[0].Name, assemblyName });
122131
}
123-
assemPath = Path.Combine(new string[] { binRoot, dirs[0].Name, runtime, assemblyName });
124-
if (File.Exists(assemPath))
132+
if (assemPath != null && File.Exists(assemPath))
125133
{
126134
return assemPath;
127135
}
128-
assemPath = Path.Combine(new string[] { binRoot, dirs[0].Name, assemblyName });
129-
}
130-
if (assemPath != null && File.Exists(assemPath))
131-
{
132-
return assemPath;
133136
}
134137
}
135138
return null;

0 commit comments

Comments
 (0)