PowerShell/Visual Studio compilation problem

I am trying to compile my Web Forms 2017 project using PowerShell. I know it can be done (and in Command Prompt), because I have done it before. I am using this script to compile the project:

$aspnetCompiler = (Join-Path $env:windir 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler') & $aspnetCompiler -p "C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb" -v /-u "C:\DimaWebCompiled_test"
The folder, DimaWeb, is the one which contains my VS project files (aspx and aspx.vb pages, images, scripts, MS Access database, etc). The folder, DimaWebCompiled_test, should contain my compiled files ready to be uploaded to my Web hosting service. I am getting this error:

/-u/DimaWeb/Account/RegisterExternalLogin.aspx(1): error ASPPARSE: The file ‘/-u/Site.master’ does not exist.

Is there another script I can try as I don’t understand the error. I do not have a file called RegisterExternalLogin.aspx(1) in my Account folder, but I do have a file called RegisterExternalLogin.aspx in my Account folder in Visual Studio. I also have a file called Site.master in Visual Studio, though I never use it.

What should I be doing, please, that I am not doing?

Thanks!

Try adding .exe to the end of the path:

$aspnetCompiler = (Join-Path $env:windir 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe')

Thanks, Rob for your reply.

I still get that same error:

/-u/DimaWeb/Account/RegisterExternalLogin.aspx(1): error ASPPARSE: The file '/-u/Site.master' does not exist. PS C:\>
Site.master does exist in the DimaWeb folder, but if I remove it and then run your script again, I still get that same error. Does that imply that it is little to do with the PS script?

Thanks again.

When you crosspost the same question you could at least let all forum where you posted know that you finally solved the problem!!!

MS Powershell forum - Parse error - file doesn’t exist (when it does).

The problem is not resolved, Olaf.

Thanks.

I think what Olaf is saying is that, on a cross post, whenever you get something that solves your use case, be sure to go back to all site you asked and post the answer.

As for my input, give this …

$aspnetCompiler = (Join-Path $env:windir 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe')
Start-Process -FilePath $aspnetCompiler -ArgumentList '-p' 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' '-v' '/-u' 'C:\DimaWebCompiled_test'

… or this a shot.

$ConsoleCommand = "$env:windir 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe' -p 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' -v /-u 'C:\DimaWebCompiled_test'"
Start-Process powershell -ArgumentList "-NoExit","-Command  &{ $ConsoleCommand }" -Wait

Hello postanote

Thanks for your reply.

With this code

$aspnetCompiler = (Join-Path $env:windir 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe') Start-Process -FilePath $aspnetCompiler -ArgumentList '-p' 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' '-v' '/-u' 'C:\DimaWebCompiled_test'
I get this in PS:

Start-Process : A positional parameter cannot be found that accepts argument ‘C:\Users\Steve\Documents\Visual Studio
2017\DimaWeb’.
At line:1 char:1

  • Start-Process -FilePath $aspnetCompiler -ArgumentList ‘-p’ 'C:\Users\ …
  • CategoryInfo : InvalidArgument: (:slight_smile: [Start-Process], ParameterBindingException
  • FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

Does that mean the path is wrong?

And with this:

$ConsoleCommand = "$env:windir 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe' -p 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' -v /-u 'C:\DimaWebCompiled_test'" Start-Process powershell -ArgumentList "-NoExit","-Command &{ $ConsoleCommand }" -Wait
Another PS window pops-up with this error:

& : The term ‘amp’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:2

  • &{ C:\WINDOWS 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compil …
  • CategoryInfo : ObjectNotFound: (amp:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

And then this code:

C:\WINDOWS 'Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe' -p 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' -v /-u 'C:\DimaWebCompiled_test' PS C:\>
I am beginning to think this may not be a scripting problem, but a missing file or something. I will take a look at the project again.

Thanks again.

Yeppers, check that and any dependencies relative to your app.

This could also just be a quoting issue and I just notice the you did not have a slash after that $env. PS will not do that for you. Also space in directory names it always a bad idea. It will eventually come back to bite you.

Try again this way:

$aspnetCompiler = "$env:windir\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe"
Start-Process -FilePath $aspnetCompiler -ArgumentList "-p 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' -v /-u C:\DimaWebCompiled_test" -Wait

# Or 

$ConsoleCommand = "$env:windir\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -p 'C:\Users\Steve\Documents\Visual Studio 2017\DimaWeb' -v /-u C:\DimaWebCompiled_test"
Start-Process powershell -ArgumentList "-NoExit","-Command &{ $ConsoleCommand }" -Wait

Since I cannot test explicitly, I can only toss ideas.

Thanks again, postanote

When I copied and pasted your first code, a screen - looked like a cmd prompt screen - rapidly popped up and then disappeared and then nothing happened. With the second set of code, a new PS screen loaded, and I got the same error:

/-u/DimaWeb/Account/RegisterExternalLogin.aspx(1): error ASPPARSE: The file '/-u/Site.master' does not exist. PS C:\>
I have escalated this to Microsoft because RegisterExternalLogin.aspx (but not RegisterExternalLogin.aspx(1) is definitely in the Account folder.

Thanks again.