I am trying to create Docker Image and while running Run dotnet build xxxxxx.csproj -c Release -o /app/build I am getting below error.
The imported project "C:\Program Files\dotnet\sdk\7.0.101\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\7.0.101\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
Can anyone suggest me the fix?
I got an answer
I was running wrong command to build a project based on ASP.Net framework 4.7.2.
Instead of using RUN DOTNET BUILD, I needed to use RUN msbuild command. It solved my issue. It is working now.
I keep getting this when I try to run or run a flutter project
/Users/user1/Projects/projectx/ios/Pods/FBSDKCoreKit_Basics/Sources/FBSDK
CoreKit_Basics/FBSDKUserDataStore.m:19:9: fatal error:
'FBSDKUserDataStore.h' file not found
#import "FBSDKUserDataStore.h"
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete
note: Removed stale file
'/Users/user1/Library/Developer/Xcode/DerivedData/Runner-axlixevsrpjdqpcqvk
bkkcevsnce/Build/Products/Debug-iphonesimulator/wakelock/wakelock.framework'
This was caused by an error in one of the dependencies, an update has been released and I was able to run the application.
I've got a build script which was designed for dotnet 2.1. This script's job is to output a docker image that runs a dotnet core app. I recently made a small change to the dotnet core app but when I went to build a container, using my script, the image didn't work. I debugged this down to dotnet 3.1 behaving differently when calling the dotnet publish command...
Here is the command I'm using in dotnet 2.1:
dotnet publish WebService --configuration %CONFIGURATION% --output bin\Docker
This creates a Docker folder in the bin folder, as expected, but when I use dotnet 3.1 this output argument appears to be ignored.
I found this on the following on MSDN:
If you're using an SDK that is newer, like 3.0, make sure that your
app is forced to use the 2.2 SDK. Create a file named global.json in
your working folder and paste in the following JSON code:
{ "sdk": {
"version": "2.2.100" } }
https://learn.microsoft.com/en-us/dotnet/core/docker/build-container
So, after finding this info on MSDN that says that I need to force dotnet to use an older version, I now have a workaround but my question is... why? Dotnet 3.1 can't build Docker images? Please help me connect the dots on what I'm missing here.
I'm trying to build my .net core project onto a docker container but it seems like it can't find Newtonsoft.Json which I thought was included in the asp.net core
Here is my docker file:
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 58373
EXPOSE 44370
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ["TestCode/TestCode.csproj", "TestCode/"]
RUN dotnet restore "TestCode/TestCode.csproj"
COPY . .
WORKDIR "/src/TestCode"
RUN dotnet build "TestCode.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "TestCode.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "TestCode.dll"]
I'm getting the following error when trying to build
Error Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
In my case, When used JsonProperty in a class,
Visual Studio intellicode auto-filled,
using Newtonsoft.Json;
Then during docker build,
warning MSB3245: Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json". Check to make sure the assembly exists on disk.
When I checked, found out that the Visual Studio added an Assembly Reference to Newtonsoft.Json (you can find this by expanding Dependencies node in the solution explorer in Visual Studio). And I was using Linux images.
So in order to solve this, I removed the Assembly Reference, and added nuget package Newtonsoft.Json, then the docker build was successful.
Found the issue. Update NuGet package Microsoft.VisualStudio.Azure.Containers.Tools.Targets to latest version and the problem goes away.
I Don't know why, but I hit this issue because of my tests projects. Once I removed my tests from the release configuration (meaning "I Don't want the test assemblies in my publish folder"), the docker file worked great. xUnit using coverlet for code coverage in net core 3.1, might help someone someday, I almost lose it.
EDIT:
Doing further research I found this is an issue in the coverlet package to track code coverage. Can be fixed using <IsPublishable>false</IsPublishable> as Billy Braga mention here https://github.com/coverlet-coverage/coverlet/issues/1045
1 way is to have your other project be part of your solution and reference it as a project reference.
or
2nd way, as a quick resolution what I did and it worked for me, is after COPY . . is to add another copy command in the docker file like:
COPY ./bin/Debug/.../your-referenced-dll-name.dll .
--Hope this helps
I have a problem with my build configuration in VS Team Services.
I try to mark my nuget packages with prerelease suffix.
I have a Utility CommandLine step defined.
Tool: dotnet
Argument: pack $(build.sourcesdirectory)/..../project.json --no-build --configuration Release --output nupkgs --version-suffix "prerelease-$(rev:.rr)"
I get the message:
"'1.0.0-prerelease-$(rev:.rr)' is not a valid version string."
If I do the same with a static:
Tool: dotnet
Argument: pack $(build.sourcesdirectory)/..../project.json --no-build --configuration Release --output nupkgs --version-suffix "prerelease-123"
That works fine.
So, it seams that the special placeholder $(rev:.rr) is not replaced, but I don't know why.
Kind regards
I found out that there are different variables for the build and release tabs.
I tried to use this token on a build definition, what didn't work.
I was able to achive what I want to do with a build token.
Kind regards