I have followed the installation instructions found here: https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-docker-edit-and-refresh/
and made an empty ASP.Net hello world project. I keep getting this error when I try to build my project:
Error MSB3073 The command "powershell -ExecutionPolicy RemoteSigned .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'" exited with code 1. HelloWorld C:\dev\HelloWorld\src\HelloWorld\Properties\Docker.targets 37
Upon further digging I get this error:
1>------ Build started: Project: HelloWorld, Configuration: Debug Any CPU ------
1>
1> Build succeeded.
1> 0 Warning(s).
1> 0 Error(s).
1>
1> Time elapsed 00:00:00.0958314
1>
1> .\Docker\DockerTask.ps1 : The term '.\Docker\DockerTask.ps1' is not recognized as the name of a cmdlet, function,
1> script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
1> correct and try again.
1> At line:1 char:1
1> + .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'
1> + ~~~~~~~~~~~~~~~~~~~~~~~
1> + CategoryInfo : ObjectNotFound: (.\Docker\DockerTask.ps1:String) [], CommandNotFoundException
1> + FullyQualifiedErrorId : CommandNotFoundException
1>
1>C:\dev\HelloWorld\src\HelloWorld\Properties\Docker.targets(37,5): error MSB3073: The command "powershell -ExecutionPolicy RemoteSigned .\Docker\DockerTask.ps1 -Build -Environment Debug -Machine 'default'" exited with code 1.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
I am using Visual Studios 2015 on Windows 10 64bit.
The problem was my working directory was set differently than the default settings. By using the get-location command I was able to figure out where the working directory was and give it the relative path from that directory.
HelloWorld\src\HelloWorld\Docker\DockerTask.ps1
Rightly pointed out by SirJackovich.
The issue was due to a mis-pointed folder path given to msbuild.
To check out what path to modify, follow these steps:
In Properties\Docker.targets,
a. Temporarily change DockerBuildCommand to <DockerBuildCommand>powershell get-location</DockerBuildCommand>.
b. Temporarily change DockerCleanCommand to <DockerCleanCommand>powershell get-location</DockerCleanCommand>.
c. Run build having Docker build target selected (instead of 'IIS Express').
d. From the trace output in the Output window, it will print the folder which is the root for execution. For example, c:\folder1 is the root execution folder for powershell.
e. Lets say DockerTask.ps1 is located in c:\folder1\MyApp\src\App1\DockerTask.ps1. Modify the DockerBuildCommand command within Properties\Docker.targets to point to MyApp\src\App1\DockerTask.ps1. Also Modify the DockerCleanCommand command to point to MyApp\src\App1\DockerTask.ps1.
powershell -ExecutionPolicy RemoteSigned MyApp\src\App1\DockerTask.ps1.ps1 -Build -Environment $(Configuration) -Machine '$(DockerMachineName)' -ClrDebugVersion VS2015U2
powershell -ExecutionPolicy RemoteSigned MyApp\src\App1\DockerTask.ps1 -Clean -Environment $(Configuration) -Machine '$(DockerMachineName)'
f. Rebuild the solution.
This will deploy the image to the default docker environment within docker-machine.
Related
I have a .NET 3.1 web api project with swaggerUI. During the Publish of this project I've set that it must generate the XML documentation so Swagger can show the comments I've inserted for each endpoint, objects returned, etc...
Then I've created a pipeline in Azure DevOps to automatically run the build on trigger changes on the master branch, but I get the following error:
Determining projects to restore...
Restored D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj (in 48.44 sec).
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB3191: Unable to create directory "E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\". Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\'. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB4181: The "MakeDir" task returned false but did not log an error. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
D:\a\1\s\XXX-DataBridges-API\Models\Context\ReportingContext.cs(58,10): warning CS1030: #warning: 'To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
CSC : error CS0016: Could not write to output file 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml' -- 'Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml'.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
Build FAILED.
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB3191: Unable to create directory "E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\". Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\'. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB4181: The "MakeDir" task returned false but did not log an error. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
D:\a\1\s\XXX-DataBridges-API\Models\Context\ReportingContext.cs(58,10): warning CS1030: #warning: 'To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
CSC : error CS0016: Could not write to output file 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml' -- 'Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml'.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
3 Warning(s)
1 Error(s)
I also see in the error message that it talks about .Net 5, "C:\Program Files\dotnet\sdk\5.0.102..." but I've specified that is Net Core 3.1.
Here is the YAML:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: MyProject_Build
Solved by modifying the path of the documentfile section in .csproj file.
setting as ".\documentation-file-name.xml" solved the error
I'm having trouble deploying a service onto a local cluster.
...
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.47
-------- Package: Project: Project succeeded, Time elapsed: 00:00:01.8640999 --------
3>Started executing script 'Deploy-FabricApplication.ps1'.
3>powershell -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command ". 'C:\repo\service\Scripts\Deploy-FabricApplication.ps1' -ApplicationPackagePath 'C:\repo\service\pkg\Debug' -PublishProfileFile 'C:\repo\service\PublishProfiles\Cloud.xml' -DeployOnly:$false -ApplicationParameter:#{} -UnregisterUnusedApplicationVersionsAfterUpgrade $false -OverrideUpgradeBehavior 'VetoUpgrade' -OverwriteBehavior 'SameAppTypeAndVersion' -SkipPackageValidation:$false -ErrorAction Stop"
3>Test-ServiceFabricApplicationPackage : The BuildLayout of the application in
3>C:\Users\username\AppData\Local\Temp\TestApplicationPackage_269749895297\o40yhtdd.vi3\Debug is invalid. Code is missing
3>for service Service.
3>At C:\Program Files\Microsoft SDKs\Service
3>Fabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:163 char:38
3>+ ... tionSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse)
3>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3> + CategoryInfo : InvalidOperation: (:) [Test-ServiceFabricApplicationPackage], FabricImageBuilderValidati
3> onException
3> + FullyQualifiedErrorId : TestApplicationPackageErrorId,Microsoft.ServiceFabric.Powershell.TestApplicationPackage
3>
3>Finished executing script 'Deploy-FabricApplication.ps1'.
3>Time elapsed: 00:00:01.4326464
3>The PowerShell script failed to execute.
========== Build: 1 succeeded or up-to-date, 0 failed, 1 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
The above error message says "...\Debug is invalid. Code is missing for service<>". How exactly do I fix this problem? What code is missing?
+I did attempt creating that file path just in case, only to find out that the filepath seems to be randomly generated. That filepath did not exist before.
+I am running VSTS 2019 with admin privilege.
You are seeing the output of a Powershell command named Test-ServiceFabricApplicationPackage. It is reporting that your package layout has an issue:
The BuildLayout of the application in {folder} is invalid. Code is
missing
You can run this script yourself to reproduce, and fix the package layout issue. Compare your package with a working package, to see where the issue is. Maybe one of your manifest files is missing a CodePackage section?
I'm trying to upgrade the sample app (Voting) from Microsoft using Visual Studio 2019.
During the update I get the following error:
4>FABRIC_E_IMAGEBUILDER_UNEXPECTED_ERROR: One or more errors occurred. --> AggregateException: One or more errors occurred. --> FileLoadException: The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
4>Registration of application type failed.
4>At C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:258 char:17
4>+ throw "Registration of application type failed."
4>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4> + CategoryInfo : OperationStopped: (Registration of application type failed.:String) [], RuntimeException
4> + FullyQualifiedErrorId : Registration of application type failed.
The full output is:
1>------ Build started: Project: VotingWeb, Configuration: Debug Any CPU ------
2>------ Build started: Project: VotingData, Configuration: Debug Any CPU ------
2>Waiting for output folder cleanup...
1>Waiting for output folder cleanup...
1>Output folder cleanup has been completed.
2>Output folder cleanup has been completed.
1>VotingWeb -> C:\DEV\Teamcity test\service-fabric-sample-app\VotingWeb\bin\Debug\net472\win7-x64\VotingWeb.exe
2>VotingData -> C:\DEV\Teamcity test\service-fabric-sample-app\VotingData\bin\Debug\net472\win7-x64\VotingData.exe
3>------ Build started: Project: Voting, Configuration: Debug x64 ------
4>------ Publish started: Project: Voting, Configuration: Debug x64 ------
4>Started executing script 'GetApplicationExistence'.
4>Finished executing script 'GetApplicationExistence'.
4>Time elapsed: 00:00:02.7466922
-------- Package started: Project: Voting, Configuration: Debug x64 ------
Das Verzeichnis ist nicht leer.
VotingData -> C:\DEV\Teamcity test\service-fabric-sample-app\VotingData\bin\Debug\net472\win7-x64\VotingData.exe
VotingData -> C:\DEV\Teamcity test\service-fabric-sample-app\VotingData\obj\Debug\net472\win7-x64\PubTmp\Out\
VotingWeb -> C:\DEV\Teamcity test\service-fabric-sample-app\VotingWeb\bin\Debug\net472\win7-x64\VotingWeb.exe
VotingWeb -> C:\DEV\Teamcity test\service-fabric-sample-app\VotingWeb\obj\Debug\net472\win7-x64\PubTmp\Out\
Voting -> C:\DEV\Teamcity test\service-fabric-sample-app\Voting\pkg\Debug
-------- Package: Project: Voting succeeded, Time elapsed: 00:00:34.0353563 --------
4>Started executing script 'Deploy-FabricApplication.ps1'.
4>powershell -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command ". 'C:\DEV\Teamcity test\service-fabric-sample-app\Voting\Scripts\Deploy-FabricApplication.ps1' -ApplicationPackagePath 'C:\DEV\Teamcity test\service-fabric-sample-app\Voting\pkg\Debug' -PublishProfileFile 'C:\DEV\Teamcity test\service-fabric-sample-app\Voting\PublishProfiles\Cloud.xml' -DeployOnly:$false -ApplicationParameter:#{} -UnregisterUnusedApplicationVersionsAfterUpgrade $false -OverrideUpgradeBehavior 'None' -OverwriteBehavior 'SameAppTypeAndVersion' -SkipPackageValidation:$false -ErrorAction Stop"
4>Application Type VotingType and Version 1.7.2 was already registered with Cluster, unregistering it...
4>Unregister application type succeeded.
4>Copying application package to image store...
4>Upload to Image Store succeeded
4>Registering application type...
4>Register application type started. Use Get-ServiceFabricApplicationType to query for status.
4>Running Image Builder process ...
4>Downloading application package from 'VotingType' ...
4>Downloaded 101/999 Files (10.1% complete)
4>Downloaded 229/999 Files (22.9% complete)
4>Downloaded 291/999 Files (29.1% complete)
4>Downloaded 363/999 Files (36.3% complete)
4>Downloaded 447/999 Files (44.7% complete)
4>Downloaded 559/999 Files (56.0% complete)
4>Validating package and computing checksums ...
4>FABRIC_E_IMAGEBUILDER_UNEXPECTED_ERROR: One or more errors occurred. --> AggregateException: One or more errors occurred. --> FileLoadException: The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
4>Registration of application type failed.
4>At C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:258 char:17
4>+ throw "Registration of application type failed."
4>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4> + CategoryInfo : OperationStopped: (Registration of application type failed.:String) [], RuntimeException
4> + FullyQualifiedErrorId : Registration of application type failed.
4>
4>Finished executing script 'Deploy-FabricApplication.ps1'.
4>Time elapsed: 00:01:44.9589058
4>The PowerShell script failed to execute.
========== Build: 3 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
How can I find out which file is in use?
And how can I fix it?
Solution:
In case that someone else faces the same issue, the solution for me was to upgrade the application using Powershell and set the CompressPackage parameter in the Copy-ServiceFabricApplicationPackage command.
Helpfull link: https://learn.microsoft.com/de-de/azure/service-fabric/service-fabric-package-apps
I am using Visual Studio 2017 and I want to add a post-build command. when I go to 'Macros' window I see the correct path coresponging to $(ProjectDir) variable. So I added the command:
$(ProjectDir)ClientApp\npm run build
but when I execute build I get the following error:
The command 'ClientApp\npm run build'exited with code 3.
I change MSBuild verbose to Diagnose and in the Output window I saw:
1>Target "PostBuildEvent" in file "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets":
1> Using "Exec" task from assembly "Microsoft.Build.Tasks.Core,
Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1> Task "Exec" 1> Task
Parameter:WorkingDirectory=bin\Debug\netcoreapp1.1\ 1> Task
Parameter:Command=ClientApp\npm run build 1> ClientApp\npm run
build 1> The system cannot find the path specified. 1>
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4933,5):
error MSB3073: The command "ClientApp\npm run build" exited with code
3. 1> Done executing task "Exec" -- FAILED.
In the targets file I got these lines:
<Target
Name="PostBuildEvent"
Condition="'$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)')"
DependsOnTargets="$(PostBuildEventDependsOn)">
<Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>
Can I change the working dir from $(OutDir) to $(ProjectDir) and how?
Any ideas where I am mistaken?
NB - I added the command in a BAT file, just to test but the result was the same
Try $(MSBuildProjectDirectory) instead
The problem could affect other VS variable as well.
The universal solution is described here.
I am compile a sample C# .NET project using build.cmd file. The content of the build.cmd is as bellow.
build.cmd
#echo off
setlocal
set devenv="c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com"
del *.log >nul
%devenv% WindowsFormsApplication3.sln /rebuild "Release" /out WindowsFormsApplication3.log
if ERRORLEVEL 1 GOTO failed
findstr /C:"========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========" WindowsFormsApplication3.log >nul
if ERRORLEVEL 1 GOTO failed
echo *** BUILD SUCCESSFUL ***
pause
goto :EOF
:failed
echo.
echo.
echo *** BUILD FAILED ***
pause
Project compiles properly. But when i opened the log file it hassome error
WindowsFormsApplication3.log
1>------ Rebuild All started: Project: WindowsFormsApplication3, Configuration: Release Any CPU ------
Package 'Code Analysis Package' failed to load.
1> WindowsFormsApplication3 -> E:\Bin\junk\WindowsFormsApplication3\WindowsFormsApplication3\bin\Release\WindowsFormsApplication3.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
I don't why i am getting this error (Package 'Code Analysis Package' failed to load) in log file.
I searched online but did not get any help.
how to solve this problem?
Note: WindowsFormsApplication3 is a sample project. i Opened VS2015 and New Project -> Visual C# -> Windows Form Application. I did not change any thing in the project.
Give Microsoft a chance to analyze and fix the problem.
I created a connect issue because the problem occurs on two PCs that both have vanilla VS 2015 installations.
https://connect.microsoft.com/VisualStudio/feedback/details/2423616/package-code-analysis-package-failed-to-load
Within the next few weeks, a guy from Microsoft will probably comment on that. You can followup there.