Open sandboxFocusImprove this doc

PS0045: Invalid Path in the Configuration of PostSharp

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 element or SearchPath element: the File attribute of a Using element, or the Path attribute of a SearchPath element, of a configuration file such as postsharp.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 a RequirePostSharp attribute or a configuration file requires.
  • Project file name or project 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 the postsharp.config files of the directory of the project and of its parent directories, and the configuration files that their Using elements 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 AssemblyOriginatorKeyFile property of the project.
  • To see which configuration files PostSharp loads and which paths it evaluates, build with the PostSharpTrace MSBuild property set to ProjectLoader, and a build log verbosity of at least normal. See Well-Known MSBuild Properties.

See Also

Other Resources

Configuring Projects Using postsharp.config
Configuration File Schema Reference
Well-Known MSBuild Properties