Skip to content

Update project.json packages and examples #2658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions examples/Browser/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,8 @@
<PackageReference Include="Grpc.AspNetCore.Web" />
</ItemGroup>

<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<!-- Include source map for debugging (for other source map options see https://webpack.js.org/configuration/devtool/ ) -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npx webpack --debug --devtool inline-source-map scripts/index.js" />
</Target>

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npx webpack scripts/index.js" />

<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)dist\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
</ItemGroup>
<Target Name="DebugEnsureJavaScriptDep" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)dist/main.js') ">
<Error Text="Run 'npm install' and 'npm run build' in the wwwroot directory to build the required JavaScript dependencies." />
</Target>

</Project>
70 changes: 20 additions & 50 deletions examples/Browser/Server/wwwroot/Scripts/greet_grpc_web_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
* @public
*/

// GENERATED CODE -- DO NOT EDIT!
// Code generated by protoc-gen-grpc-web. DO NOT EDIT.
// versions:
// protoc-gen-grpc-web v1.5.0
// protoc v6.31.1
// source: greet.proto


/* eslint-disable */
// @ts-nocheck



Expand All @@ -17,15 +25,15 @@ proto.greet = require('./greet_pb.js');
/**
* @param {string} hostname
* @param {?Object} credentials
* @param {?Object} options
* @param {?grpc.web.ClientOptions} options
* @constructor
* @struct
* @final
*/
proto.greet.GreeterClient =
function(hostname, credentials, options) {
if (!options) options = {};
options['format'] = 'text';
options.format = 'text';

/**
* @private @const {!grpc.web.GrpcWebClientBase} The client
Expand All @@ -35,23 +43,23 @@ proto.greet.GreeterClient =
/**
* @private @const {string} The hostname
*/
this.hostname_ = hostname;
this.hostname_ = hostname.replace(/\/+$/, '');

};


/**
* @param {string} hostname
* @param {?Object} credentials
* @param {?Object} options
* @param {?grpc.web.ClientOptions} options
* @constructor
* @struct
* @final
*/
proto.greet.GreeterPromiseClient =
function(hostname, credentials, options) {
if (!options) options = {};
options['format'] = 'text';
options.format = 'text';

/**
* @private @const {!grpc.web.GrpcWebClientBase} The client
Expand All @@ -61,7 +69,7 @@ proto.greet.GreeterPromiseClient =
/**
* @private @const {string} The hostname
*/
this.hostname_ = hostname;
this.hostname_ = hostname.replace(/\/+$/, '');

};

Expand All @@ -88,31 +96,12 @@ const methodDescriptor_Greeter_SayHello = new grpc.web.MethodDescriptor(
);


/**
* @const
* @type {!grpc.web.AbstractClientBase.MethodInfo<
* !proto.greet.HelloRequest,
* !proto.greet.HelloReply>}
*/
const methodInfo_Greeter_SayHello = new grpc.web.AbstractClientBase.MethodInfo(
proto.greet.HelloReply,
/**
* @param {!proto.greet.HelloRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.greet.HelloReply.deserializeBinary
);


/**
* @param {!proto.greet.HelloRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.Error, ?proto.greet.HelloReply)}
* @param {function(?grpc.web.RpcError, ?proto.greet.HelloReply)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.greet.HelloReply>|undefined}
* The XHR Node Readable Stream
Expand All @@ -131,10 +120,10 @@ proto.greet.GreeterClient.prototype.sayHello =
/**
* @param {!proto.greet.HelloRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!Promise<!proto.greet.HelloReply>}
* A native promise that resolves to the response
* Promise that resolves to the response
*/
proto.greet.GreeterPromiseClient.prototype.sayHello =
function(request, metadata) {
Expand Down Expand Up @@ -168,28 +157,9 @@ const methodDescriptor_Greeter_SayHellos = new grpc.web.MethodDescriptor(
);


/**
* @const
* @type {!grpc.web.AbstractClientBase.MethodInfo<
* !proto.greet.HelloRequest,
* !proto.greet.HelloReply>}
*/
const methodInfo_Greeter_SayHellos = new grpc.web.AbstractClientBase.MethodInfo(
proto.greet.HelloReply,
/**
* @param {!proto.greet.HelloRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.greet.HelloReply.deserializeBinary
);


/**
* @param {!proto.greet.HelloRequest} request The request proto
* @param {?Object<string, string>} metadata User defined
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!grpc.web.ClientReadableStream<!proto.greet.HelloReply>}
* The XHR Node Readable Stream
Expand All @@ -206,7 +176,7 @@ proto.greet.GreeterClient.prototype.sayHellos =

/**
* @param {!proto.greet.HelloRequest} request The request proto
* @param {?Object<string, string>} metadata User defined
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!grpc.web.ClientReadableStream<!proto.greet.HelloReply>}
* The XHR Node Readable Stream
Expand Down
15 changes: 12 additions & 3 deletions examples/Browser/Server/wwwroot/Scripts/greet_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
/**
* @fileoverview
* @enhanceable
* @suppress {missingRequire} reports error on implicit type usages.
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public
*/
// GENERATED CODE -- DO NOT EDIT!
/* eslint-disable */
// @ts-nocheck

var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
var global =
(typeof globalThis !== 'undefined' && globalThis) ||
(typeof window !== 'undefined' && window) ||
(typeof global !== 'undefined' && global) ||
(typeof self !== 'undefined' && self) ||
(function () { return this; }).call(null) ||
Function('return this')();

goog.exportSymbol('proto.greet.HelloReply', null, global);
goog.exportSymbol('proto.greet.HelloRequest', null, global);
Expand Down Expand Up @@ -88,7 +97,7 @@ proto.greet.HelloRequest.prototype.toObject = function(opt_includeInstance) {
*/
proto.greet.HelloRequest.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, "")
name: jspb.Message.getFieldWithDefault(msg, 1, "")
};

if (includeInstance) {
Expand Down Expand Up @@ -218,7 +227,7 @@ proto.greet.HelloReply.prototype.toObject = function(opt_includeInstance) {
*/
proto.greet.HelloReply.toObject = function(includeInstance, msg) {
var f, obj = {
message: jspb.Message.getFieldWithDefault(msg, 1, "")
message: jspb.Message.getFieldWithDefault(msg, 1, "")
};

if (includeInstance) {
Expand Down
Loading