| Severity | Error |
| Reported by | PostSharp |
| Message | Invalid path passed to PostSharp (<Location>): "<Path>": <Reason> |
Cause
Before it uses a path to a file, PostSharp checks that the runtime accepts it as a path. PostSharp reports PS0045, and stops building the project, when the runtime rejects the path. <Location> says where the path comes from:
Using elementorSearchPath element: theFileattribute of aUsingelement, or thePathattribute of aSearchPathelement, of a configuration file such aspostsharp.config, after PostSharp has evaluated the expressions that it contains. See Configuration File Schema Reference.plug-in name: the name of a plug-in that aRequirePostSharpattribute or a configuration file requires.Project file nameorproject or configuration file name: a project or configuration file that PostSharp loads.private key location: the key file that signs the assembly, which the build passes to PostSharp.
<Path> is the path as PostSharp read it, with its directory separators normalized, and <Reason> is the explanation of the runtime.
Which paths the runtime rejects depends on the runtime that runs PostSharp. On .NET Framework, a path is invalid when it contains characters such as |, <, > or ", or a colon elsewhere than after the drive letter. On .NET, almost every path is accepted, and PostSharp checks before that the paths of configuration files are not empty, so PS0045 practically occurs only when PostSharp runs on .NET Framework.
This message depends on the runtime that runs PostSharp, and the test projects of this documentation run PostSharp on .NET, so no example can show it.
Resolution
- Look at
<Location>and<Path>in the message to find the path. For a configuration file, search thepostsharp.configfiles of the directory of the project and of its parent directories, and the configuration files that theirUsingelements import. - Remove the invalid characters from the path. When the path is built from an expression such as
{$SolutionDir}, check the value of each property that the expression uses: an MSBuild property that contains several paths or quotes, for example, does not make a valid path. - For the private key location, check the
AssemblyOriginatorKeyFileproperty of the project. - To see which configuration files PostSharp loads and which paths it evaluates, build with the
PostSharpTraceMSBuild property set toProjectLoader, and a build log verbosity of at leastnormal. See Well-Known MSBuild Properties.
See Also
Other Resources
Configuring Projects Using postsharp.config
Configuration File Schema Reference
Well-Known MSBuild Properties