Kauan
Kauan
CC#
Created by Keyvan on 1/17/2025 in #help
Dockerizing dotnet
42 replies
CC#
Created by Keyvan on 1/17/2025 in #help
Dockerizing dotnet
after restoring the packages, you need to build the project and publish it. Here's an example
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["src/WebApi/WebApi.csproj", "WebApi/"]
COPY ["src/Application/Application.csproj", "Application/"]
COPY ["src/Domain/Domain.csproj", "Domain/"]
COPY ["src/Contracts/Contracts.csproj", "Contracts/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "Infrastructure/"]
COPY ["Directory.Packages.props", "./"]
COPY ["Directory.Build.props", "./"]
RUN dotnet restore "WebApi/WebApi.csproj"
COPY . ../
WORKDIR /src/WebApi
RUN dotnet build "WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish --no-restore -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:9.0
ENV ASPNETCORE_HTTP_PORTS=5001
EXPOSE 5001
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApi.dll"]
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["src/WebApi/WebApi.csproj", "WebApi/"]
COPY ["src/Application/Application.csproj", "Application/"]
COPY ["src/Domain/Domain.csproj", "Domain/"]
COPY ["src/Contracts/Contracts.csproj", "Contracts/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "Infrastructure/"]
COPY ["Directory.Packages.props", "./"]
COPY ["Directory.Build.props", "./"]
RUN dotnet restore "WebApi/WebApi.csproj"
COPY . ../
WORKDIR /src/WebApi
RUN dotnet build "WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish --no-restore -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:9.0
ENV ASPNETCORE_HTTP_PORTS=5001
EXPOSE 5001
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApi.dll"]
42 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
Thanks for the advice, I'll file the issue
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
Failed to subscribe to active projects: Error: Activating the "Microsoft.VisualStudio.ProjectSystem.Query.Remoting.QueryExecutionService (0.3)" service failed.
Starting Query for all projects...
Failed at 'Query for all projects' (0ms) with error: Error: Activating the "Microsoft.VisualStudio.ProjectSystem.Query.Remoting.QueryExecutionService (0.3)" service failed.
Failed to subscribe to active projects: Error: Activating the "Microsoft.VisualStudio.ProjectSystem.Query.Remoting.QueryExecutionService (0.3)" service failed.
Starting Query for all projects...
Failed at 'Query for all projects' (0ms) with error: Error: Activating the "Microsoft.VisualStudio.ProjectSystem.Query.Remoting.QueryExecutionService (0.3)" service failed.
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
but something is still missing because the autocomplete and syntax highlighting is not working
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
the environment variable was wrong, after running the command . ~/.asdf/plugins/dotnet-core/set-dotnet-home.zsh to update it and also changing the dotnetAcquisitionExtension.existingDotnetPath to the following:
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "ms-dotnettools.csharp",
"path": "/home/kauan/.asdf/installs/dotnet-core/9.0.100/dotnet"
},
{
"extensionId": "ms-dotnettools.csdevkit",
"path": "/home/kauan/.asdf/installs/dotnet-core/9.0.100/dotnet"
}
]
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "ms-dotnettools.csharp",
"path": "/home/kauan/.asdf/installs/dotnet-core/9.0.100/dotnet"
},
{
"extensionId": "ms-dotnettools.csdevkit",
"path": "/home/kauan/.asdf/installs/dotnet-core/9.0.100/dotnet"
}
]
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
but I think I found something here
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
It didn't work
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
No description
31 replies
CC#
Created by Kauan on 1/16/2025 in #help
C# Dev Kit Extension Syntax Highlighting and Autocomplete Not Working After Updating to .NET 9
asdf is a runtime configuration manager
31 replies
CC#
Created by reeeeeee on 1/15/2025 in #help
Where to handle mapping between DTOs and Entity objects?
You could do the projection in the database side and already return the response/dto from your service
public async Task<ErrorOr<UserResponse>> Handle(
GetCurrentUserQuery query,
CancellationToken cancellationToken)
{
var user = await _context.Users
.AsNoTracking()
.Where(u => u.Id == _userContext.UserId)
.Select(u => new UserResponse
{
Id = u.Id,
Email = u.Email,
FirstName = u.FirstName,
LastName = u.LastName,
FullName = u.FullName,
ImageUrl = u.ImageUrl,
})
.FirstOrDefaultAsync(cancellationToken);

if (user is null)
{
return UserErrors.NotFound;
}

return user;
}
public async Task<ErrorOr<UserResponse>> Handle(
GetCurrentUserQuery query,
CancellationToken cancellationToken)
{
var user = await _context.Users
.AsNoTracking()
.Where(u => u.Id == _userContext.UserId)
.Select(u => new UserResponse
{
Id = u.Id,
Email = u.Email,
FirstName = u.FirstName,
LastName = u.LastName,
FullName = u.FullName,
ImageUrl = u.ImageUrl,
})
.FirstOrDefaultAsync(cancellationToken);

if (user is null)
{
return UserErrors.NotFound;
}

return user;
}
4 replies